Statuses.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Status column for Cache grid
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Backend\Block\Cache\Grid\Column;
  9. /**
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Statuses extends \Magento\Backend\Block\Widget\Grid\Column
  14. {
  15. /**
  16. * @var \Magento\Framework\App\Cache\TypeListInterface
  17. */
  18. protected $_cacheTypeList;
  19. /**
  20. * @param \Magento\Backend\Block\Template\Context $context
  21. * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
  22. * @param array $data
  23. */
  24. public function __construct(
  25. \Magento\Backend\Block\Template\Context $context,
  26. \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
  27. array $data = []
  28. ) {
  29. parent::__construct($context, $data);
  30. $this->_cacheTypeList = $cacheTypeList;
  31. }
  32. /**
  33. * Add to column decorated status
  34. *
  35. * @return array
  36. */
  37. public function getFrameCallback()
  38. {
  39. return [$this, 'decorateStatus'];
  40. }
  41. /**
  42. * Decorate status column values
  43. *
  44. * @param string $value
  45. * @param \Magento\Framework\Model\AbstractModel $row
  46. * @param \Magento\Backend\Block\Widget\Grid\Column $column
  47. * @param bool $isExport
  48. * @return string
  49. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  50. */
  51. public function decorateStatus($value, $row, $column, $isExport)
  52. {
  53. $invalidedTypes = $this->_cacheTypeList->getInvalidated();
  54. if (isset($invalidedTypes[$row->getId()])) {
  55. $cell = '<span class="grid-severity-minor"><span>' . __('Invalidated') . '</span></span>';
  56. } else {
  57. if ($row->getStatus()) {
  58. $cell = '<span class="grid-severity-notice"><span>' . $value . '</span></span>';
  59. } else {
  60. $cell = '<span class="grid-severity-critical"><span>' . $value . '</span></span>';
  61. }
  62. }
  63. return $cell;
  64. }
  65. }