/** * Reders an element as output. * * @param AbstractEntity $element Element * @param string $subpartName Template subpart name * @param array $typoscript TypoScript array for rendering * @param string $prefix Prefix for Marker, optional# * @param string $markerWrap SecondPrefix for Marker, default ### * @param string $template Template * * @return string HTML-Content */ public function renderElement(AbstractEntity $element, $subpartName, array $typoscript, $prefix = '', $markerWrap = '###', $template = '') { if (empty($subpartName)) { return $this->error('renderElement', __LINE__, 'No supart defined for class.CommerceTeam\\Commerce\\Controller\\BaseController::renderElement'); } if (strlen($template) < 1) { $template = $this->template; } if (empty($template)) { return $this->error('renderElement', __LINE__, 'No Template given as parameter to method and no template loaded via TS'); } $output = $this->cObj->getSubpart($template, $subpartName); if (empty($output)) { return $this->error('renderElement', __LINE__, 'class.tx_commerce_pibase::renderElement: Subpart:' . $subpartName . ' not found in HTML-Code', $template); } $data = $element->returnAssocArray(); $markerArray = $this->generateMarkerArray($data, $typoscript); $hooks = HookFactory::getHooks('Controller/BaseController', 'renderElement'); foreach ($hooks as $hook) { if (method_exists($hook, 'additionalMarkerElement')) { $markerArray = $hook->additionalMarkerElement($markerArray, $element, $this); } } if ($prefix > '') { $markerWrap .= strtoupper($prefix) . '_'; } $markerWrap .= '|###'; if (is_array($markerArray) && !empty($markerArray)) { $output = $this->cObj->substituteMarkerArray($output, $markerArray, $markerWrap, 1); $output = $this->cObj->stdWrap($output, $typoscript['stdWrap.']); } else { $output = ''; } return $output; }
/** * Returns the data of this object als array. * * @param string $prefix Prefix for the keys or returnung array optional * * @return array Assoc Arry of data */ public function returnAssocArray($prefix = '') { $data = parent::returnAssocArray($prefix); $data[$prefix . 'stock'] = $this->getStock(); return $data; }