protected function Atom::_setId in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Atom.php \Zend\Feed\Writer\Renderer\Entry\Atom::_setId()
Set entry identifier
Parameters
DOMDocument $dom:
DOMElement $root:
Return value
void
Throws
Writer\Exception\InvalidArgumentException
1 call to Atom::_setId()
- Atom::render in vendor/
zendframework/ zend-feed/ src/ Writer/ Renderer/ Entry/ Atom.php - Render atom entry
File
- vendor/
zendframework/ zend-feed/ src/ Writer/ Renderer/ Entry/ Atom.php, line 249
Class
Namespace
Zend\Feed\Writer\Renderer\EntryCode
protected function _setId(DOMDocument $dom, DOMElement $root) {
if (!$this
->getDataContainer()
->getId() && !$this
->getDataContainer()
->getLink()) {
$message = 'Atom 1.0 entry elements MUST contain exactly one ' . 'atom:id element, or as an alternative, we can use the same ' . 'value as atom:link however neither a suitable link nor an ' . 'id have been set';
$exception = new Writer\Exception\InvalidArgumentException($message);
if (!$this->ignoreExceptions) {
throw $exception;
}
else {
$this->exceptions[] = $exception;
return;
}
}
if (!$this
->getDataContainer()
->getId()) {
$this
->getDataContainer()
->setId($this
->getDataContainer()
->getLink());
}
if (!Uri::factory($this
->getDataContainer()
->getId())
->isValid() && !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\\-]{1,31}:([a-zA-Z0-9\\(\\)\\+\\,\\.\\:\\=\\@\\;\$\\_\\!\\*\\-]|%[0-9a-fA-F]{2})*#", $this
->getDataContainer()
->getId()) && !$this
->_validateTagUri($this
->getDataContainer()
->getId())) {
throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI');
}
$id = $dom
->createElement('id');
$root
->appendChild($id);
$text = $dom
->createTextNode($this
->getDataContainer()
->getId());
$id
->appendChild($text);
}