protected function Rss::_setEnclosure in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Rss.php \Zend\Feed\Writer\Renderer\Entry\Rss::_setEnclosure()
Set entry enclosure
Parameters
DOMDocument $dom:
DOMElement $root:
Return value
void
Throws
Writer\Exception\InvalidArgumentException
1 call to Rss::_setEnclosure()
- Rss::render in vendor/
zendframework/ zend-feed/ src/ Writer/ Renderer/ Entry/ Rss.php - Render RSS entry
File
- vendor/
zendframework/ zend-feed/ src/ Writer/ Renderer/ Entry/ Rss.php, line 201
Class
Namespace
Zend\Feed\Writer\Renderer\EntryCode
protected function _setEnclosure(DOMDocument $dom, DOMElement $root) {
$data = $this->container
->getEnclosure();
if (!$data || empty($data)) {
return;
}
if (!isset($data['type'])) {
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "type" is not set');
if (!$this->ignoreExceptions) {
throw $exception;
}
else {
$this->exceptions[] = $exception;
return;
}
}
if (!isset($data['length'])) {
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" is not set');
if (!$this->ignoreExceptions) {
throw $exception;
}
else {
$this->exceptions[] = $exception;
return;
}
}
if ((int) $data['length'] < 0 || !ctype_digit((string) $data['length'])) {
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" must be an integer' . ' indicating the content\'s length in bytes');
if (!$this->ignoreExceptions) {
throw $exception;
}
else {
$this->exceptions[] = $exception;
return;
}
}
$enclosure = $this->dom
->createElement('enclosure');
$enclosure
->setAttribute('type', $data['type']);
$enclosure
->setAttribute('length', $data['length']);
$enclosure
->setAttribute('url', $data['uri']);
$root
->appendChild($enclosure);
}