Newscoop\Service\Implementation\ThemeServiceLocalFileSystem::loadTheme PHP Method

loadTheme() protected method

Loads the theme object.
protected loadTheme ( SimpleXMLElement $nodeTheme, string $id, string $themeConfig ) : Theme
$nodeTheme SimpleXMLElement The node Theme XML element, *(not null not empty).
$id string The id of the loaded Theme, *(not null not empty).
$themeConfig string The path of the Theme XML file in order to extract the theme path, *(not null not empty).
return Newscoop\Entity\Theme The loaded theme object, NULL if there was an issue.
    protected function loadTheme(\SimpleXMLElement $nodeTheme, $id, $themeConfig)
    {
        if ($nodeTheme->getName() !== self::TAG_THEME) {
            $this->getErrorHandler()->error(ThemeErrors::XML_NO_ROOT);
            return NULL;
        }
        $theme = new Theme();
        $theme->setId($id);
        $theme->setPath($this->extractRelativePathFrom($themeConfig));
        try {
            $theme->setName($this->readAttribute($nodeTheme, self::ATTR_THEME_NAME));
            $theme->setDesigner($this->readAttribute($nodeTheme, self::ATTR_THEME_DESIGNER));
            $theme->setVersion($this->readAttribute($nodeTheme, self::ATTR_THEME_VERSION));
            $theme->setMinorNewscoopVersion($this->readAttribute($nodeTheme, self::ATTR_THEME_NEWSCOOP_VERSION));
            $theme->setDescription($nodeTheme->{self::TAG_DESCRIPTION}->__toString());
        } catch (XMLMissingAttribueException $e) {
            $this->getErrorHandler()->error(ThemeErrors::XML_MISSING_ATTRIBUTE, $e->getAttributeName(), $nodeTheme->getName());
            return NULL;
        }
        return $theme;
    }