Chris@0: container = $container; Chris@0: $this->setType($container->getType()); Chris@0: $this->_loadExtensions(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Save XML to string Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function saveXml() Chris@0: { Chris@12: return $this->getDomDocument()->saveXML(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get DOM document Chris@0: * Chris@0: * @return DOMDocument Chris@0: */ Chris@0: public function getDomDocument() Chris@0: { Chris@0: return $this->dom; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get document element from DOM Chris@0: * Chris@0: * @return DOMElement Chris@0: */ Chris@0: public function getElement() Chris@0: { Chris@0: return $this->getDomDocument()->documentElement; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get data container of items being rendered Chris@0: * Chris@0: * @return Writer\AbstractFeed Chris@0: */ Chris@0: public function getDataContainer() Chris@0: { Chris@0: return $this->container; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set feed encoding Chris@0: * Chris@0: * @param string $enc Chris@0: * @return AbstractRenderer Chris@0: */ Chris@0: public function setEncoding($enc) Chris@0: { Chris@0: $this->encoding = $enc; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get feed encoding Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getEncoding() Chris@0: { Chris@0: return $this->encoding; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Indicate whether or not to ignore exceptions Chris@0: * Chris@0: * @param bool $bool Chris@0: * @return AbstractRenderer Chris@0: * @throws Writer\Exception\InvalidArgumentException Chris@0: */ Chris@0: public function ignoreExceptions($bool = true) Chris@0: { Chris@12: if (! is_bool($bool)) { Chris@12: throw new Writer\Exception\InvalidArgumentException( Chris@12: 'Invalid parameter: $bool. Should be TRUE or FALSE (defaults to TRUE if null)' Chris@12: ); Chris@0: } Chris@0: $this->ignoreExceptions = $bool; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get exception list Chris@0: * Chris@0: * @return array Chris@0: */ Chris@0: public function getExceptions() Chris@0: { Chris@0: return $this->exceptions; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set the current feed type being exported to "rss" or "atom". This allows Chris@0: * other objects to gracefully choose whether to execute or not, depending Chris@0: * on their appropriateness for the current type, e.g. renderers. Chris@0: * Chris@0: * @param string $type Chris@0: */ Chris@0: public function setType($type) Chris@0: { Chris@0: $this->type = $type; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Retrieve the current or last feed type exported. Chris@0: * Chris@0: * @return string Value will be "rss" or "atom" Chris@0: */ Chris@0: public function getType() Chris@0: { Chris@0: return $this->type; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the absolute root element for the XML feed being generated. This Chris@0: * helps simplify the appending of namespace declarations, but also ensures Chris@0: * namespaces are added to the root element - not scattered across the entire Chris@0: * XML file - may assist namespace unsafe parsers and looks pretty ;). Chris@0: * Chris@0: * @param DOMElement $root Chris@0: */ Chris@0: public function setRootElement(DOMElement $root) Chris@0: { Chris@0: $this->rootElement = $root; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Retrieve the absolute root element for the XML feed being generated. Chris@0: * Chris@0: * @return DOMElement Chris@0: */ Chris@0: public function getRootElement() Chris@0: { Chris@0: return $this->rootElement; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Load extensions from Zend\Feed\Writer\Writer Chris@0: * Chris@0: * @return void Chris@0: */ Chris@12: // @codingStandardsIgnoreStart Chris@0: protected function _loadExtensions() Chris@0: { Chris@12: // @codingStandardsIgnoreEnd Chris@0: Writer\Writer::registerCoreExtensions(); Chris@0: $manager = Writer\Writer::getExtensionManager(); Chris@0: $all = Writer\Writer::getExtensions(); Chris@16: $exts = stripos(get_class($this), 'entry') Chris@16: ? $all['entryRenderer'] Chris@16: : $all['feedRenderer']; Chris@0: foreach ($exts as $extension) { Chris@0: $plugin = $manager->get($extension); Chris@0: $plugin->setDataContainer($this->getDataContainer()); Chris@0: $plugin->setEncoding($this->getEncoding()); Chris@0: $this->extensions[$extension] = $plugin; Chris@0: } Chris@0: } Chris@0: }