Esempio n. 1
0
 public function load($filename)
 {
     $theme = new Theme();
     $xml = file_get_contents($filename);
     $rootNode = new SimpleXMLElement($xml);
     $theme->setBasePath(dirname($filename));
     $theme->setName((string) $rootNode['name']);
     foreach ($rootNode->block as $blockNode) {
         $block = new Block();
         $block->setName((string) $blockNode['name']);
         $block->setType((string) $blockNode['type']);
         $block->setGlobal((string) $blockNode['global']);
         $block->setEditable((string) $blockNode['editable']);
         $block->setHeader((string) $blockNode->header);
         $block->setFooter((string) $blockNode->footer);
         foreach ($blockNode->property as $propertyNode) {
             $property = new Property();
             $property->setName((string) $propertyNode['name']);
             $property->setLanguage((string) $propertyNode['language']);
             $property->setValue((string) $propertyNode);
             $block->setProperty($property);
         }
         $theme->addBlock($block);
     }
     return $theme;
 }
Esempio n. 2
0
 private function loadProperties($propertyNodes, $container)
 {
     foreach ($propertyNodes as $propertyNode) {
         $property = new Property();
         $property->setName((string) $propertyNode['name']);
         $property->setLanguage((string) $propertyNode['language']);
         $property->setValue((string) $propertyNode);
         $container->setProperty($property);
     }
 }
Esempio n. 3
0
 public function setProperty(Property $property)
 {
     if ($property->getLanguage() == '') {
         throw new InvalidArgumentException("Property doesn't have a language: " . $property->getName() . " with value " . $property->getValue());
     }
     if (strpos($property->getName(), '_') > 0) {
         throw new InvalidArgumentException("Property name should not contain underscores: " . $property->getName() . " with value " . $property->getValue());
     }
     if (!isset($this->properties[$property->getLanguage()])) {
         $this->properties[$property->getLanguage()] = array();
     }
     $this->properties[$property->getLanguage()][$property->getName()] = $property;
 }