Searchquery.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\Dashboard\Searches\Renderer;
  7. /**
  8. * Dashboard search query column renderer
  9. * @api
  10. * @since 100.0.2
  11. */
  12. class Searchquery extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
  13. {
  14. /**
  15. * String helper
  16. *
  17. * @var \Magento\Framework\Stdlib\StringUtils
  18. */
  19. protected $stringHelper;
  20. /**
  21. * @param \Magento\Backend\Block\Context $context
  22. * @param \Magento\Framework\Stdlib\StringUtils $stringHelper
  23. * @param array $data
  24. */
  25. public function __construct(
  26. \Magento\Backend\Block\Context $context,
  27. \Magento\Framework\Stdlib\StringUtils $stringHelper,
  28. array $data = []
  29. ) {
  30. $this->stringHelper = $stringHelper;
  31. parent::__construct($context, $data);
  32. }
  33. /**
  34. * Renders a column
  35. *
  36. * @param \Magento\Framework\DataObject $row
  37. * @return string
  38. */
  39. public function render(\Magento\Framework\DataObject $row)
  40. {
  41. $value = $row->getData($this->getColumn()->getIndex());
  42. if ($this->stringHelper->strlen($value) > 30) {
  43. $value = '<span title="' . $this->escapeHtml(
  44. $value
  45. ) . '">' . $this->escapeHtml(
  46. $this->filterManager->truncate($value, ['length' => 30])
  47. ) . '</span>';
  48. } else {
  49. $value = $this->escapeHtml($value);
  50. }
  51. return $value;
  52. }
  53. }