Page.php 925 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Cms\Model\Config\Source;
  7. use Magento\Cms\Model\ResourceModel\Page\CollectionFactory;
  8. /**
  9. * Class Page
  10. */
  11. class Page implements \Magento\Framework\Option\ArrayInterface
  12. {
  13. /**
  14. * @var array
  15. */
  16. protected $options;
  17. /**
  18. * @var CollectionFactory
  19. */
  20. protected $collectionFactory;
  21. /**
  22. * @param CollectionFactory $collectionFactory
  23. */
  24. public function __construct(
  25. CollectionFactory $collectionFactory
  26. ) {
  27. $this->collectionFactory = $collectionFactory;
  28. }
  29. /**
  30. * To option array
  31. *
  32. * @return array
  33. */
  34. public function toOptionArray()
  35. {
  36. if (!$this->options) {
  37. $this->options = $this->collectionFactory->create()->toOptionIdArray();
  38. }
  39. return $this->options;
  40. }
  41. }