public function tag($type, $realName, $options = [])
{
$type = strtolower($type);
$document = $this->document;
$name = Model\Document\Tag::buildTagName($type, $realName, $document);
try {
if ($document instanceof Model\Document\PageSnippet) {
$tag = $document->getElement($name);
if ($tag instanceof Model\Document\Tag && $tag->getType() == $type) {
// call the load() method if it exists to reinitialize the data (eg. from serializing, ...)
if (method_exists($tag, "load")) {
$tag->load();
}
// set view & controller, editmode
$tag->setController($this->controller);
$tag->setView($this);
$tag->setEditmode($this->editmode);
$tag->setOptions($options);
} else {
$tag = Model\Document\Tag::factory($type, $name, $document->getId(), $options, $this->controller, $this, $this->editmode);
$document->setElement($name, $tag);
}
// set the real name of this editable, without the prefixes and suffixes from blocks and areablocks
$tag->setRealName($realName);
}
return $tag;
} catch (\Exception $e) {
Logger::warning($e);
}
}