State.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Status\Grid\Column;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class State extends \Magento\Backend\Block\Widget\Grid\Column
  12. {
  13. /**
  14. * @var \Magento\Sales\Model\Order\Config
  15. */
  16. protected $_config;
  17. /**
  18. * @param \Magento\Backend\Block\Template\Context $context
  19. * @param \Magento\Sales\Model\Order\Config $config
  20. * @param array $data
  21. */
  22. public function __construct(
  23. \Magento\Backend\Block\Template\Context $context,
  24. \Magento\Sales\Model\Order\Config $config,
  25. array $data = []
  26. ) {
  27. parent::__construct($context, $data);
  28. $this->_config = $config;
  29. }
  30. /**
  31. * Add decorated status to column
  32. *
  33. * @return array
  34. */
  35. public function getFrameCallback()
  36. {
  37. return [$this, 'decorateState'];
  38. }
  39. /**
  40. * Decorate status column values
  41. *
  42. * @param string $value
  43. * @param \Magento\Sales\Model\Order\Status $row
  44. * @param \Magento\Backend\Block\Widget\Grid\Column $column
  45. * @param bool $isExport
  46. * @return string
  47. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  48. */
  49. public function decorateState($value, $row, $column, $isExport)
  50. {
  51. $status = $row->getStatus();
  52. if ($value) {
  53. $cell = $value . '[' . $this->_config->getStateLabelByStateAndStatus($value, $status) . ']';
  54. } else {
  55. $cell = $value;
  56. }
  57. return $cell;
  58. }
  59. }