src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php
protected function generateTemplates(Webspace $webspace)
    {
        $defaultErrorTemplates = 0;

        foreach ($this->xpath->query('/x:webspace/x:theme/x:error-templates/x:error-template') as $errorTemplateNode) {
            /* @var \DOMNode $errorTemplateNode */
            $template = $errorTemplateNode->nodeValue;
            if (null !== ($codeNode = $errorTemplateNode->attributes->getNamedItem('code'))) {
                $webspace->addTemplate('error-' . $codeNode->nodeValue, $template);
            } elseif (null !== ($defaultNode = $errorTemplateNode->attributes->getNamedItem('default'))) {
                $default = 'true' === $defaultNode->nodeValue;
                if (!$default) {
                    throw new InvalidDefaultErrorTemplateException($template, $this->webspace->getKey());
                }
                ++$defaultErrorTemplates;
                $webspace->addTemplate('error', $template);
            } else {
                throw new InvalidErrorTemplateException($template, $this->webspace->getKey());
            }
        }

        // only one or none default error-template is legal
        if ($defaultErrorTemplates > 1) {
            throw new InvalidAmountOfDefaultErrorTemplateException($this->webspace->getKey());
        }

        return $webspace;
    }
protected function generateTemplates(Webspace $webspace)
    {
        $defaultErrorTemplates = 0;

        foreach ($this->xpath->query('/x:webspace/x:theme/x:error-templates/x:error-template') as $errorTemplateNode) {
            /* @var \DOMNode $errorTemplateNode */
            $template = $errorTemplateNode->nodeValue;
            if (null !== ($codeNode = $errorTemplateNode->attributes->getNamedItem('code'))) {
                $webspace->addTemplate('error-' . $codeNode->nodeValue, $template);
            } elseif (null !== ($defaultNode = $errorTemplateNode->attributes->getNamedItem('default'))) {
                $default = 'true' === $defaultNode->nodeValue;
                if (!$default) {
                    throw new InvalidDefaultErrorTemplateException($template, $this->webspace->getKey());
                }
                ++$defaultErrorTemplates;
                $webspace->addTemplate('error', $template);
            } else {
                throw new InvalidErrorTemplateException($template, $this->webspace->getKey());
            }
        }

        // only one or none default error-template is legal
        if ($defaultErrorTemplates > 1) {
            throw new InvalidAmountOfDefaultErrorTemplateException($this->webspace->getKey());
        }

        return $webspace;
    }
protected function generateTemplates ( Webspace $ webspace ) { $ defaultErrorTemplates = 0 ; foreach ( $ this -> xpath -> query ( '/x:webspace/x:theme/x:error-templates/x:error-template' ) as $ errorTemplateNode ) { /* @var \DOMNode $errorTemplateNode */ $ template = $ errorTemplateNode -> nodeValue ; if ( null !== ( $ codeNode = $ errorTemplateNode -> attributes -> getNamedItem ( 'code' ) ) ) { $ webspace -> addTemplate ( 'error-' . $ codeNode -> nodeValue , $ template ) ; } elseif ( null !== ( $ defaultNode = $ errorTemplateNode -> attributes -> getNamedItem ( 'default' ) ) ) { $ default = 'true' === $ defaultNode -> nodeValue ; if ( ! $ default ) { throw new InvalidDefaultErrorTemplateException ( $ template , $ this -> webspace -> getKey ( ) ) ; } ++ $ defaultErrorTemplates ; $ webspace -> addTemplate ( 'error' , $ template ) ; } else { throw new InvalidErrorTemplateException ( $ template , $ this -> webspace -> getKey ( ) ) ; } } // only one or none default error-template is legal if ( $ defaultErrorTemplates > 1 ) { throw new InvalidAmountOfDefaultErrorTemplateException ( $ this -> webspace -> getKey ( ) ) ; } return $ webspace ; }
Generates the available template types for the given webspace.

@param Webspace $webspace

@return Webspace

@throws InvalidAmountOfDefaultErrorTemplateException
@throws InvalidDefaultErrorTemplateException
@throws InvalidErrorTemplateException
Generates the available template types for the given webspace .