Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractRenderer.php
Go to the documentation of this file.
1 <?php
7 
10 
19 {
23  protected $_defaultWidth;
24 
28  protected $_column;
29 
34  public function setColumn($column)
35  {
36  $this->_column = $column;
37  return $this;
38  }
39 
43  public function getColumn()
44  {
45  return $this->_column;
46  }
47 
54  public function render(DataObject $row)
55  {
56  if ($this->getColumn()->getEditable()) {
57  $result = '<div class="admin__grid-control">';
58  $result .= $this->getColumn()->getEditOnly() ? ''
59  : '<span class="admin__grid-control-value">' . $this->_getValue($row) . '</span>';
60 
61  return $result . $this->_getInputValueElement($row) . '</div>' ;
62  }
63  return $this->_getValue($row);
64  }
65 
72  public function renderExport(DataObject $row)
73  {
74  return $this->render($row);
75  }
76 
81  protected function _getValue(DataObject $row)
82  {
83  if ($getter = $this->getColumn()->getGetter()) {
84  if (is_string($getter)) {
85  return $row->{$getter}();
86  } elseif (is_callable($getter)) {
87  return call_user_func($getter, $row);
88  }
89  return '';
90  }
91  return $row->getData($this->getColumn()->getIndex());
92  }
93 
99  {
100  return '<input type="text" class="input-text ' .
101  $this->getColumn()->getValidateClass() .
102  '" name="' .
103  $this->getColumn()->getId() .
104  '" value="' .
105  $this->_getInputValue(
106  $row
107  ) . '"/>';
108  }
109 
114  protected function _getInputValue(DataObject $row)
115  {
116  return $this->_getValue($row);
117  }
118 
122  public function renderHeader()
123  {
124  if (false !== $this->getColumn()->getSortable()) {
125  $className = 'not-sort';
126  $dir = strtolower($this->getColumn()->getDir());
127  $nDir = $dir == 'asc' ? 'desc' : 'asc';
128  if ($this->getColumn()->getDir()) {
129  $className = '_' . $dir . 'end';
130  }
131  $out = '<th data-sort="' .
132  $this->getColumn()->getId() .
133  '" data-direction="' .
134  $nDir .
135  '" class="data-grid-th _sortable ' .
136  $className . ' ' .
137  $this->getColumn()->getHeaderCssClass() .
138  '"><span>' .
139  $this->getColumn()->getHeader() .
140  '</span></th>';
141  } else {
142  $out = '<th class="data-grid-th ' .
143  $this->getColumn()->getHeaderCssClass() . '"><span>' .
144  $this->getColumn()->getHeader() .
145  '</span></th>';
146  }
147  return $out;
148  }
149 
153  public function renderProperty()
154  {
155  $out = '';
156  $width = $this->_defaultWidth;
157 
158  if ($this->getColumn()->hasData('width')) {
159  $customWidth = $this->getColumn()->getData('width');
160  if (null === $customWidth || preg_match('/^[0-9]+%?$/', $customWidth)) {
161  $width = $customWidth;
162  } elseif (preg_match('/^([0-9]+)px$/', $customWidth, $matches)) {
163  $width = (int)$matches[1];
164  }
165  }
166 
167  if (null !== $width) {
168  $out .= ' width="' . $width . '"';
169  }
170 
171  return $out;
172  }
173 
177  public function renderCss()
178  {
179  return $this->getColumn()->getCssClass();
180  }
181 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31