SchemaLocator.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Menu configuration schema locator
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\Config;
  9. use Magento\Framework\Config\Dom\UrnResolver;
  10. /**
  11. * Class SchemaLocator provides the information about xsd schema to be used for a configuration validation
  12. * Current class can be configured through di.xml
  13. * The default value of realPath variable contains information about view.xsd to keep the backward compatibility.
  14. */
  15. class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
  16. {
  17. /**
  18. * Path to corresponding XSD file with validation rules for merged config
  19. *
  20. * @var string
  21. */
  22. protected $schema = null;
  23. /**
  24. * SchemaLocator constructor.
  25. *
  26. * @param UrnResolver $urnResolver
  27. * @param string $realPath
  28. */
  29. public function __construct(
  30. UrnResolver $urnResolver,
  31. $realPath = 'urn:magento:framework:Config/etc/view.xsd'
  32. ) {
  33. $this->schema = $urnResolver->getRealPath($realPath);
  34. }
  35. /**
  36. * Get path to merged config schema
  37. *
  38. * @return string|null
  39. */
  40. public function getSchema()
  41. {
  42. return $this->schema;
  43. }
  44. /**
  45. * Get path to pre file validation schema
  46. *
  47. * @return string|null
  48. */
  49. public function getPerFileSchema()
  50. {
  51. return $this->getSchema();
  52. }
  53. }