LazyLoad.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Model\Config\Source;
  9. /**
  10. * Lazy load options
  11. */
  12. class LazyLoad implements \Magento\Framework\Option\ArrayInterface
  13. {
  14. const DISABLED = 0;
  15. const ENABLED_WITH_AUTO_TRIGER = 1;
  16. const ENABLED_WITHOUT_AUTO_TRIGER = 2;
  17. /**
  18. * Options getter
  19. *
  20. * @return array
  21. */
  22. public function toOptionArray()
  23. {
  24. return [
  25. ['value' => self::DISABLED, 'label' => __('No')],
  26. ['value' => self::ENABLED_WITH_AUTO_TRIGER, 'label' => __('Yes (With auto trigger)')],
  27. ['value' => self::ENABLED_WITHOUT_AUTO_TRIGER, 'label' => __('Yes (Without auto trigger)')],
  28. ];
  29. }
  30. /**
  31. * Get options in "key-value" format
  32. *
  33. * @return array
  34. */
  35. public function toArray()
  36. {
  37. $array = [];
  38. foreach($this->toOptionArray() as $item) {
  39. $array[$item['value']] = $item['label'];
  40. }
  41. return $array;
  42. }
  43. }