-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathSchemaLocator.php
66 lines (60 loc) · 1.73 KB
/
SchemaLocator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\FunctionalTestingFramework\Config;
/**
* Configuration schema locator.
*/
class SchemaLocator implements \Magento\FunctionalTestingFramework\Config\SchemaLocatorInterface
{
/**
* Path to corresponding XSD file with validation rules for merged config.
*
* @var string
*/
private $schemaPath;
/**
* Path to corresponding XSD file with validation rules for separate config files.
*
* @var string
*/
private $perFileSchema;
/**
* Class constructor
*
* @param string $schemaPath
* @param string|null $perFileSchema
*/
public function __construct($schemaPath, $perFileSchema = null)
{
if (constant('FW_BP') && file_exists(FW_BP . DIRECTORY_SEPARATOR . $schemaPath)) {
$this->schemaPath = FW_BP . DIRECTORY_SEPARATOR . $schemaPath;
$this->perFileSchema = $perFileSchema === null ? null : FW_BP . DIRECTORY_SEPARATOR . $perFileSchema;
} else {
$path = dirname(dirname(dirname(__DIR__)));
$path = str_replace('\\', DIRECTORY_SEPARATOR, $path);
$this->schemaPath = $path . DIRECTORY_SEPARATOR . $schemaPath;
$this->perFileSchema = $perFileSchema === null ? null : $path . DIRECTORY_SEPARATOR . $perFileSchema;
}
}
/**
* Get path to merged config schema
*
* @return string
*/
public function getSchema()
{
return $this->schemaPath;
}
/**
* Get path to pre file validation schema
*
* @return null
*/
public function getPerFileSchema()
{
return $this->perFileSchema;
}
}