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