src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php
protected function generateLocalizationFromNode(\DOMElement $localizationNode, $flat = false, $parent = null)
    {
        $localization = new Localization();
        $localization->setLanguage($localizationNode->attributes->getNamedItem('language')->nodeValue);

        // set parent if given
        if ($parent) {
            $localization->setParent($parent);
        }

        // set optional nodes
        $countryNode = $localizationNode->attributes->getNamedItem('country');
        if ($countryNode) {
            $localization->setCountry($countryNode->nodeValue);
        }

        $shadowNode = $localizationNode->attributes->getNamedItem('shadow');
        if ($shadowNode) {
            $localization->setShadow($shadowNode->nodeValue);
        }

        $defaultNode = $localizationNode->attributes->getNamedItem('default');
        if ($defaultNode) {
            $localization->setDefault('true' == $defaultNode->nodeValue);
        } else {
            $localization->setDefault(false);
        }

        $xDefaultNode = $localizationNode->attributes->getNamedItem('x-default');
        if ($xDefaultNode) {
            $localization->setXDefault('true' == $xDefaultNode->nodeValue);
        } else {
            $localization->setXDefault(false);
        }

        // set child nodes
        if (!$flat) {
            foreach ($this->xpath->query('x:localization', $localizationNode) as $childNode) {
                $localization->addChild($this->generateLocalizationFromNode($childNode, $flat, $localization));
            }
        }

        return $localization;
    }
protected function generateLocalizationFromNode(\DOMElement $localizationNode, $flat = false, $parent = null)
    {
        $localization = new Localization();
        $localization->setLanguage($localizationNode->attributes->getNamedItem('language')->nodeValue);

        // set parent if given
        if ($parent) {
            $localization->setParent($parent);
        }

        // set optional nodes
        $countryNode = $localizationNode->attributes->getNamedItem('country');
        if ($countryNode) {
            $localization->setCountry($countryNode->nodeValue);
        }

        $shadowNode = $localizationNode->attributes->getNamedItem('shadow');
        if ($shadowNode) {
            $localization->setShadow($shadowNode->nodeValue);
        }

        $defaultNode = $localizationNode->attributes->getNamedItem('default');
        if ($defaultNode) {
            $localization->setDefault('true' == $defaultNode->nodeValue);
        } else {
            $localization->setDefault(false);
        }

        $xDefaultNode = $localizationNode->attributes->getNamedItem('x-default');
        if ($xDefaultNode) {
            $localization->setXDefault('true' == $xDefaultNode->nodeValue);
        } else {
            $localization->setXDefault(false);
        }

        // set child nodes
        if (!$flat) {
            foreach ($this->xpath->query('x:localization', $localizationNode) as $childNode) {
                $localization->addChild($this->generateLocalizationFromNode($childNode, $flat, $localization));
            }
        }

        return $localization;
    }
protected function generateLocalizationFromNode ( \ DOMElement $ localizationNode , $ flat = false , $ parent = null ) { $ localization = new Localization ( ) ; $ localization -> setLanguage ( $ localizationNode -> attributes -> getNamedItem ( 'language' ) -> nodeValue ) ; // set parent if given if ( $ parent ) { $ localization -> setParent ( $ parent ) ; } // set optional nodes $ countryNode = $ localizationNode -> attributes -> getNamedItem ( 'country' ) ; if ( $ countryNode ) { $ localization -> setCountry ( $ countryNode -> nodeValue ) ; } $ shadowNode = $ localizationNode -> attributes -> getNamedItem ( 'shadow' ) ; if ( $ shadowNode ) { $ localization -> setShadow ( $ shadowNode -> nodeValue ) ; } $ defaultNode = $ localizationNode -> attributes -> getNamedItem ( 'default' ) ; if ( $ defaultNode ) { $ localization -> setDefault ( 'true' == $ defaultNode -> nodeValue ) ; } else { $ localization -> setDefault ( false ) ; } $ xDefaultNode = $ localizationNode -> attributes -> getNamedItem ( 'x-default' ) ; if ( $ xDefaultNode ) { $ localization -> setXDefault ( 'true' == $ xDefaultNode -> nodeValue ) ; } else { $ localization -> setXDefault ( false ) ; } // set child nodes if ( ! $ flat ) { foreach ( $ this -> xpath -> query ( 'x:localization' , $ localizationNode ) as $ childNode ) { $ localization -> addChild ( $ this -> generateLocalizationFromNode ( $ childNode , $ flat , $ localization ) ) ; } } return $ localization ; }
Generates a localization from the given node.

@param \DOMElement|\DOMNode $localizationNode
@param bool $flat
@param null $parent

@return Localization
Generates a localization from the given node .