/** * @see Document\Tag\TagInterface::frontend * @return string */ public function frontend() { if ($this->getView() instanceof \Zend_View) { try { if ($this->snippet instanceof Document\Snippet) { $params = $this->options; $params["document"] = $this->snippet; if ($this->snippet->isPublished()) { // check if output-cache is enabled, if so, we're also using the cache here $cacheKey = null; if ($cacheConfig = \Pimcore\Tool\Frontend::isOutputCacheEnabled()) { // cleanup params to avoid serializing Element\ElementInterface objects $cacheParams = $params; array_walk($cacheParams, function (&$value, $key) { if ($value instanceof Model\Element\ElementInterface) { $value = $value->getId(); } }); $cacheKey = "tag_snippet__" . md5(serialize($cacheParams)); if ($content = Cache::load($cacheKey)) { return $content; } } $content = $this->getView()->action($this->snippet->getAction(), $this->snippet->getController(), $this->snippet->getModule(), $params); // write contents to the cache, if output-cache is enabled if ($cacheConfig) { Cache::save($content, $cacheKey, array("output", "output_inline"), $cacheConfig["lifetime"]); } // we need to add a component id to all first level html containers $componentId = 'document:' . $this->getDocumentId() . '.type:tag-snippet.name:' . $this->snippet->getId(); $content = \Pimcore\Tool\Frontend::addComponentIdToHtml($content, $componentId); return $content; } return ""; } } catch (\Exception $e) { if (\Pimcore::inDebugMode()) { return "ERROR: " . $e->getMessage() . " (for details see debug.log)"; } \Logger::error($e); } } else { return null; } }