FieldPlugin.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Paypal\Model\Config\Structure\Element;
  7. use Magento\Config\Model\Config\Structure\Element\Field as FieldConfigStructure;
  8. use Magento\Paypal\Model\Config\StructurePlugin as ConfigStructurePlugin;
  9. /**
  10. * Plugin for \Magento\Config\Model\Config\Structure\Element\Field
  11. */
  12. class FieldPlugin
  13. {
  14. /**
  15. * Get original configPath (not changed by PayPal configuration inheritance)
  16. *
  17. * @param FieldConfigStructure $subject
  18. * @param string|null $result
  19. * @return string|null
  20. */
  21. public function afterGetConfigPath(FieldConfigStructure $subject, $result)
  22. {
  23. if (!$result && strpos($subject->getPath(), 'payment_') === 0) {
  24. $result = preg_replace(
  25. '@^(' . implode('|', ConfigStructurePlugin::getPaypalConfigCountries(true)) . ')/@',
  26. 'payment/',
  27. $subject->getPath()
  28. );
  29. }
  30. return $result;
  31. }
  32. }