Example #1
0
 protected function parseClasses(dom\collection $children)
 {
     $aResult = array();
     while ($child = $children->current()) {
         if ($child->getType() == $child::ELEMENT) {
             if ($this->useNamespace($child->getNamespace())) {
                 if ($child->getName() == 'class') {
                     $aResult[] = $this->reflectClass($child);
                 } else {
                     $this->parseChildrenElementSelf($child, $aResult);
                 }
             } else {
                 $this->parseChildrenElementForeign($child, $aResult);
             }
         }
         $children->next();
     }
     return $aResult;
 }
Example #2
0
 protected function reflectImportsDynamic(dom\collection $children, $aChildren)
 {
     $window = $this->getWindow();
     //$self = $window->createVariable('self', $this->getHandlerInstance());
     $closure = $window->createClosure();
     $bChildren = false;
     $window->setScope($closure);
     $import = $children->current();
     $handler = $this->reflectImportDynamic($import);
     if ($children->length > 1 || $aChildren) {
         $bChildren = true;
         $children->next();
         while ($children->current()) {
             $import = $children->current();
             $this->mergeArguments($handler->getVar(), $this->reflectImportDynamic($import));
             $children->next();
         }
         if ($aChildren) {
             $array = $window->argToInstance($aChildren);
             $this->mergeArguments($handler->getVar(), $array);
         }
         $closure->addContent($handler->getVar());
     }
     if ($import->getParent()->isRoot()) {
         $call = $window->createCall($handler->getVar(), 'asArray', 'php-array');
         $closure->addContent($call);
     } else {
         if (!$bChildren) {
             $closure->addContent($handler);
         }
     }
     $window->stopScope();
     return $closure;
 }
Example #3
0
 /**
  * TODO? : rename parseCollection, parseCollectionElement and parseCollectionText (+node,+...)
  * @param $children
  * @return array
  */
 protected function parseChildren(dom\collection $children)
 {
     $aResult = $mResult = array();
     while ($child = $children->current()) {
         switch ($child->getType()) {
             case $child::ELEMENT:
                 $this->parseChildrenElement($child, $aResult);
                 break;
             case $child::TEXT:
                 $this->parseChildrenText($child, $aResult);
                 break;
             default:
                 $this->parseChildrenOther($child, $aResult);
         }
         $children->next();
     }
     //$this->show($aResult, false);
     return $aResult;
 }
Example #4
0
 protected function parseArguments(dom\collection $children)
 {
     $aResult = array();
     $iKey = 0;
     while ($child = $children->current()) {
         switch ($child->getType()) {
             case dom\node::TEXT:
                 $aResult[] = $this->getManager()->parse($child);
                 break;
             case dom\node::ELEMENT:
                 if ($child->isElement('call', $this->getNamespace())) {
                     break 2;
                 } else {
                     if ($child->getNamespace() == $this->getNamespace()) {
                         if (in_array($child->getName(), array('if', 'if-not'))) {
                             break 2;
                         }
                     }
                 }
                 $aArgument = $this->parseArgument($child, $iKey);
                 $aResult[$aArgument['name']] = $aArgument['value'];
                 $child->remove();
                 break;
             default:
                 $this->throwException(sprintf('Cannot use %s, valid argument expected', $child->asToken()));
         }
         $children->next();
         $iKey++;
     }
     return $aResult;
 }