GridPerPage.php 879 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Catalog\Model\Config\Source;
  7. /**
  8. * Catalog products per page on Grid mode source
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. class GridPerPage implements \Magento\Framework\Option\ArrayInterface
  13. {
  14. /**
  15. * Options
  16. *
  17. * @var array
  18. */
  19. protected $_options;
  20. /**
  21. * Constructor
  22. *
  23. * @param string $perPageValues
  24. */
  25. public function __construct($perPageValues)
  26. {
  27. $this->_options = explode(',', $perPageValues);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function toOptionArray()
  33. {
  34. $result = [];
  35. foreach ($this->_options as $option) {
  36. $result[] = ['value' => $option, 'label' => $option];
  37. }
  38. return $result;
  39. }
  40. }