Longtext.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
  7. /**
  8. * @api
  9. * @deprecated 100.2.0 in favour of UI component implementation
  10. * @since 100.0.2
  11. */
  12. class Longtext extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
  13. {
  14. /**
  15. * Render contents as a long text
  16. *
  17. * Text will be truncated as specified in string_limit, truncate or 250 by default
  18. * Also it can be html-escaped and nl2br()
  19. *
  20. * @param \Magento\Framework\DataObject $row
  21. * @return string
  22. */
  23. public function render(\Magento\Framework\DataObject $row)
  24. {
  25. $truncateLength = 250;
  26. // stringLength() is for legacy purposes
  27. if ($this->getColumn()->getStringLimit()) {
  28. $truncateLength = $this->getColumn()->getStringLimit();
  29. }
  30. if ($this->getColumn()->getTruncate()) {
  31. $truncateLength = $this->getColumn()->getTruncate();
  32. }
  33. $text = $this->filterManager->truncate(parent::_getValue($row), ['length' => $truncateLength]);
  34. if (!$this->getColumn()->hasEscape() || $this->getColumn()->getEscape()) {
  35. $text = $this->escapeHtml($text);
  36. }
  37. if ($this->getColumn()->getNl2br()) {
  38. $text = nl2br($text);
  39. }
  40. return $text;
  41. }
  42. }