Exemple #1
0
 public function build()
 {
     // Instantiate the component
     $component = $this->buildOpenTag();
     foreach ($this->attributes as $key => $attr) {
         // Id must be a unique T_ATTRIBUTE
         if ($attr->getValue() == 'id') {
             // If component's id is not set yet
             if (is_null($component->getId())) {
                 $component->setId($this->values[$key]->getValue());
                 // Add the id into the Symbols Table
                 if (!Symbols::addId($component->getId(), $component)) {
                     throw ExceptionFactory::createDuplicatedId(__FILE__, __LINE__, $this->file->getFileName(), $this->file->getCurrentLine(), $component->getId());
                 }
             } else {
                 // Duplicated T_ATTRIBUTE id
                 throw ExceptionFactory::createDuplicatedTagId(__FILE__, __LINE__, $this->file->getFileName(), $this->file->getCurrentLine());
             }
             // It's not an id
             continue;
         }
         // Set other properties
         $component->{$attr->getValue()} = $this->values[$key]->getValue();
     }
     // Clean up the old parameters
     $this->cleanUp();
     return $component;
 }