Label.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Theme_Label class used for system configuration
  8. */
  9. namespace Magento\Framework\View\Design\Theme;
  10. class Label implements \Magento\Framework\Option\ArrayInterface
  11. {
  12. /**
  13. * Labels collection array
  14. *
  15. * @var array
  16. */
  17. protected $_labelsCollection;
  18. /**
  19. * Constructor
  20. *
  21. * @param \Magento\Framework\View\Design\Theme\Label\ListInterface $labelList
  22. */
  23. public function __construct(\Magento\Framework\View\Design\Theme\Label\ListInterface $labelList)
  24. {
  25. $this->_labelsCollection = $labelList;
  26. }
  27. /**
  28. * Return labels collection array
  29. *
  30. * @param bool|string $label add empty values to result with specific label
  31. * @return array
  32. */
  33. public function getLabelsCollection($label = false)
  34. {
  35. $options = $this->_labelsCollection->getLabels();
  36. if ($label) {
  37. array_unshift($options, ['value' => '', 'label' => $label]);
  38. }
  39. return $options;
  40. }
  41. /**
  42. * Return labels collection for backend system configuration with empty value "No Theme"
  43. *
  44. * @return array
  45. */
  46. public function getLabelsCollectionForSystemConfiguration()
  47. {
  48. return $this->toOptionArray();
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function toOptionArray()
  54. {
  55. return $this->getLabelsCollection((string)new \Magento\Framework\Phrase('-- No Theme --'));
  56. }
  57. }