SchemaLocator.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Locator for payment config XSD schemas.
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Payment\Model\Config;
  9. use Magento\Framework\Module\Dir;
  10. class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
  11. {
  12. /**
  13. * Merged config schema file name
  14. */
  15. const MERGED_CONFIG_SCHEMA = 'payment.xsd';
  16. /**
  17. * Per file validation schema file name
  18. */
  19. const PER_FILE_VALIDATION_SCHEMA = 'payment_file.xsd';
  20. /**
  21. * Path to corresponding XSD file with validation rules for merged config
  22. *
  23. * @var string
  24. */
  25. protected $_schema = null;
  26. /**
  27. * Path to corresponding XSD file with validation rules for separate config files
  28. *
  29. * @var string
  30. */
  31. protected $_perFileSchema = null;
  32. /**
  33. * @param \Magento\Framework\Module\Dir\Reader $moduleReader
  34. */
  35. public function __construct(\Magento\Framework\Module\Dir\Reader $moduleReader)
  36. {
  37. $etcDir = $moduleReader->getModuleDir(\Magento\Framework\Module\Dir::MODULE_ETC_DIR, 'Magento_Payment');
  38. $this->_schema = $etcDir . '/' . self::MERGED_CONFIG_SCHEMA;
  39. $this->_perFileSchema = $etcDir . '/' . self::PER_FILE_VALIDATION_SCHEMA;
  40. }
  41. /**
  42. * Get path to merged config schema
  43. *
  44. * @return string|null
  45. */
  46. public function getSchema()
  47. {
  48. return $this->_schema;
  49. }
  50. /**
  51. * Get path to per file validation schema
  52. *
  53. * @return string|null
  54. */
  55. public function getPerFileSchema()
  56. {
  57. return $this->_perFileSchema;
  58. }
  59. }