Newscoop\Service\Implementation\ThemeManagementServiceLocal::loadOutputResource PHP Method

loadOutputResource() protected method

Reads the resources from an output tag.
protected loadOutputResource ( SimpleXMLElement $parent, string $tagName, string $themePath ) : Resource
$parent SimpleXMLElement The parent output node to read the resources from, *(not null not empty).
$tagName string The tag name containing the resource, *(not null not empty).
$themePath string The theme path to construct the resource path based on, *(not null not empty).
return Newscoop\Entity\Resource The obtained resource, not null.
    protected function loadOutputResource(\SimpleXMLElement $parent, $tagName, $themePath)
    {
        $nodes = $this->getNodes($parent, $tagName);
        if (count($nodes) == 0) {
            $this->getErrorHandler()->error(ThemeErrors::XML_MISSING_TAG, $tagName, $parent->getName());
            throw new FailedException();
        }
        if (count($nodes) > 1) {
            $this->getErrorHandler()->error(ThemeErrors::XML_TO_MANY_TAGS, $tagName, $parent->getName(), 1);
            throw new FailedException();
        }
        $node = $nodes[0];
        /* @var $node \SimpleXMLElement */
        try {
            $rsc = new Resource();
            $rsc->setName($tagName);
            $rsc->setPath($this->escapePath($themePath . $this->readAttribute($node, self::ATTR_PAGE_SRC)));
            return $rsc;
        } catch (XMLMissingAttribueException $e) {
            $this->getErrorHandler()->error(ThemeErrors::XML_MISSING_ATTRIBUTE, $e->getAttributeName(), $tagName);
            throw new FailedException();
        }
    }