Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Wrapline.php
Go to the documentation of this file.
1 <?php
7 
14 class Wrapline extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
15 {
21  protected $_defaultMaxLineLength = 60;
22 
28  protected $string;
29 
35  public function __construct(
36  \Magento\Backend\Block\Context $context,
37  \Magento\Framework\Stdlib\StringUtils $string,
38  array $data = []
39  ) {
40  $this->string = $string;
41  parent::__construct($context, $data);
42  }
43 
50  public function render(\Magento\Framework\DataObject $row)
51  {
52  $line = parent::_getValue($row);
53  $wrappedLine = '';
54  $lineLength = $this->getColumn()->getData(
55  'lineLength'
56  ) ? $this->getColumn()->getData(
57  'lineLength'
59  for ($i = 0, $n = floor($this->string->strlen($line) / $lineLength); $i <= $n; $i++) {
60  $wrappedLine .= $this->string->substr($line, $lineLength * $i, $lineLength) . "<br />";
61  }
62  return $wrappedLine;
63  }
64 }
__construct(\Magento\Backend\Block\Context $context, \Magento\Framework\Stdlib\StringUtils $string, array $data=[])
Definition: Wrapline.php:35
$i
Definition: gallery.phtml:31
render(\Magento\Framework\DataObject $row)
Definition: Wrapline.php:50