/** * @param string $position * @param array $args * @return string|void */ public function renderPosition($position, $args = array()) { // init vars $elements = array(); $output = array(); $style = isset($args['style']) ? $args['style'] : 'order.payment'; $layout = $this->_layout; // render elements foreach ($this->_getConfigPosition($position) as $index => $data) { if ($element = $this->_order->getPaymentElement($data['identifier'])) { if (!$element->canAccess() || !$element->hasValue()) { continue; } $data['_layout'] = $this->_layout; $data['_position'] = $position; $data['_index'] = $index; // set params $params = array_merge((array) $data, $args); // check value $elements[] = compact('element', 'params'); } } foreach ($elements as $i => $data) { $c = $i; $c++; $output[$i] = parent::render('element.' . $style, array('element' => $data['element'], 'params' => array_merge(array('first' => $i == 0, 'last' => $i == count($elements) - 1), $data['params']))); } $this->_layout = $layout; if (isset($args['rowAttrs']) && is_array($args['rowAttrs'])) { $rowOutput = ''; $_rowAttrs = array('class' => 'grid-row jsHeightFixRow'); $rowAttrs = array_replace_recursive($_rowAttrs, $args['rowAttrs']); $column = isset($args['column']) ? (int) $args['column'] : 3; $rowElements = array_chunk($output, $column); foreach ($rowElements as $elements) { $rowOutput .= '<div ' . $this->app->jbhtml->buildAttrs($rowAttrs) . '>'; foreach ($elements as $element) { $rowOutput .= $element; } $rowOutput .= '</div>'; } return $rowOutput; } return implode(PHP_EOL, $output); }