Identity.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\Model\Config\Source\Email;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class Identity implements \Magento\Framework\Option\ArrayInterface
  12. {
  13. /**
  14. * Email Identity options
  15. *
  16. * @var array
  17. */
  18. protected $_options = null;
  19. /**
  20. * Configuration structure
  21. *
  22. * @var \Magento\Config\Model\Config\Structure
  23. */
  24. protected $_configStructure;
  25. /**
  26. * @param \Magento\Config\Model\Config\Structure $configStructure
  27. */
  28. public function __construct(\Magento\Config\Model\Config\Structure $configStructure)
  29. {
  30. $this->_configStructure = $configStructure;
  31. }
  32. /**
  33. * Retrieve list of options
  34. *
  35. * @return array
  36. */
  37. public function toOptionArray()
  38. {
  39. if ($this->_options === null) {
  40. $this->_options = [];
  41. /** @var $section \Magento\Config\Model\Config\Structure\Element\Section */
  42. $section = $this->_configStructure->getElement('trans_email');
  43. /** @var $group \Magento\Config\Model\Config\Structure\Element\Group */
  44. foreach ($section->getChildren() as $group) {
  45. $this->_options[] = [
  46. 'value' => preg_replace('#^ident_(.*)$#', '$1', $group->getId()),
  47. 'label' => $group->getLabel(),
  48. ];
  49. }
  50. ksort($this->_options);
  51. }
  52. return $this->_options;
  53. }
  54. }