Collection.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Cache grid collection
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Backend\Model\Cache\ResourceModel\Grid;
  9. /**
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Collection extends \Magento\Framework\Data\Collection
  14. {
  15. /**
  16. * @var \Magento\Framework\App\Cache\TypeListInterface
  17. */
  18. protected $_cacheTypeList;
  19. /**
  20. * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
  21. * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
  22. */
  23. public function __construct(
  24. \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
  25. \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
  26. ) {
  27. $this->_cacheTypeList = $cacheTypeList;
  28. parent::__construct($entityFactory);
  29. }
  30. /**
  31. * Load data
  32. *
  33. * @param bool $printQuery
  34. * @param bool $logQuery
  35. * @return $this
  36. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  37. */
  38. public function loadData($printQuery = false, $logQuery = false)
  39. {
  40. if (!$this->isLoaded()) {
  41. foreach ($this->_cacheTypeList->getTypes() as $type) {
  42. $this->addItem($type);
  43. }
  44. $this->_setIsLoaded(true);
  45. }
  46. return $this;
  47. }
  48. }