Example #1
0
 protected function parseElementSelf(dom\element $el)
 {
     if ($el->getName() === 'resource') {
         $result = $this->reflectResource($el);
     } else {
         $result = parent::parseElementSelf($el);
     }
     return $result;
 }
Example #2
0
 protected function parseElementSelf(dom\element $el)
 {
     switch ($el->getName()) {
         case 'template':
             $result = $this->loadTemplate($el);
             break;
         default:
             $result = parent::parseElementSelf($el);
     }
     return $result;
 }
Example #3
0
 protected function parseElementSelf(dom\element $el)
 {
     $result = null;
     switch ($el->getName()) {
         case 'classes':
             $result = $this->reflectClasses($el);
             break;
             //case 'class' : $result = $this->reflectClass($el); break;
         //case 'class' : $result = $this->reflectClass($el); break;
         case 'base':
             $this->reflectBase($el);
             break;
         default:
             $this->throwException(sprintf('Unknown element %s', $el->asToken()));
     }
     return $result;
 }
Example #4
0
 protected function parseElementSelf(dom\element $el)
 {
     switch ($el->getName()) {
         case 'global':
             $this->setGlobal($this->parseComponent($el));
             break;
         case 'view':
         case 'route':
             $this->parsePath($el);
             break;
         case 'group':
             $this->parseGroup($el);
             break;
         default:
             $this->launchException('Unknown route', get_defined_vars());
     }
 }
Example #5
0
 protected function addSchemaChild(dom\element $el, $sNamespace)
 {
     switch ($el->getName()) {
         case 'table':
             $sResult = $this->addSchemaElement($el, $sNamespace);
             $new = $this->lookupElement($sResult, $sNamespace);
             foreach ($el->getChildren() as $child) {
                 if ($child->getType() === $child::COMMENT) {
                     continue;
                 }
                 switch ($child->getName()) {
                     case 'foreign':
                         $this->addNamespace($child->readx('@table'), $new, $el);
                         break;
                     case 'reference':
                         $this->addNamespace($child->readx('@foreign'), $new, $el);
                         break;
                 }
             }
             /*
                     $node = $this->lookupElement($sResult, $sNamespace);
             
                     foreach ($el->getx('@foreign | @table') as $child) {
             
             
                     }
             */
             //$this->browseSchemaChild($el, $sNamespace);
             break;
         case 'field':
         case 'foreign':
         case 'reference':
             $this->launchException('Should not be added (or should it ?)');
         default:
             $sResult = parent::addSchemaChild($el, $sNamespace);
     }
     return $sResult;
 }
Example #6
0
 protected function loadRule(dom\element $el, array &$aResult)
 {
     $aResult[$el->getName()] = $el->readx('@value', array(), false);
 }
Example #7
0
 /**
  * Build a new element from the source element, cannot copy cause of following steps
  *
  * - Check for foreign attributes.
  *   They define result if exists with @method parseAttributesForeign([new element]) (1st pass)
  * - Add parsed children to new element.
  * - Inform foreign attributes parser that element has been parsed with @method $parser->onClose
  *   This allow parsers to edit new element (2nd pass)
  *
  * These steps give the ability to attribute parsers to return element into new container
  *
  * @param dom\element $el
  * @return dom\element|mixed The new element or, if foreign attributes exists, result of parsing, so if result
  *         is changed on 1st pass and changes happened to new element on 2nd pass, they will we be ignored.
  */
 protected function loadElementUnknown(dom\element $el)
 {
     $newElement = $this->createElement($el->getName(), null, array(), $el->getNamespace());
     if ($this->useForeignAttributes($el)) {
         $aForeigns = $this->getForeignAttributes($el, $newElement);
         $mResult = $this->parseAttributesForeign($el, $newElement, $aForeigns);
     } else {
         foreach ($el->getAttributes() as $attr) {
             $newElement->add($this->parseAttribute($attr));
         }
         $mResult = $newElement;
     }
     $aParsers = $this->getAttributeParsers();
     $this->setAttributeParsers();
     //$this->startElement($newElement);
     if ($aChildren = $this->parseChildren($el->getChildren())) {
         $newElement->add($aChildren);
     }
     //$this->stopElement();
     return $mResult;
 }
Example #8
0
 protected function parseElementArgument(dom\element $el)
 {
     $result = null;
     switch ($el->getName()) {
         case 'import':
             break;
         case 'element':
             break;
             //case 'item' : $result = $this->reflectItem($el); break;
         //case 'item' : $result = $this->reflectItem($el); break;
         default:
             $this->throwException(sprintf('Unknown element %s', $el->asToken()));
     }
     return $result;
 }
Example #9
0
 protected function addSchemaChild(dom\element $el, $sNamespace)
 {
     $sName = '';
     switch ($el->getName()) {
         case 'element':
             $sName = $this->addSchemaElement($el, $sNamespace);
             //$this->browseSchemaChild($el, $sNamespace);
             break;
         case 'complexType':
         case 'simpleType':
             $sName = $this->addSchemaType($el, $sNamespace);
             break;
         default:
             $this->getDocument()->add($el);
     }
     return $sName;
 }
Example #10
0
 public function includeElement(dom\element $el, dom\element $ext = null)
 {
     $sPrefixes = 'extension-element-prefixes';
     if ($this->isEmpty()) {
         $this->throwException(sprintf('Cannot import in empty template'));
     }
     if ($sResult = $el->getAttribute($sPrefixes)) {
         if ($sTarget = $this->getAttribute($sPrefixes)) {
             $aTarget = explode(' ', $sTarget);
             $aResult = $aPrefixes = array_diff(explode(' ', $sResult), $aTarget);
         } else {
             $aTarget = array();
             $aResult = $aPrefixes = explode(' ', $sResult);
         }
         foreach ($aPrefixes as $iPrefix => $sPrefix) {
             if (!$this->getNamespace($sPrefix)) {
                 if ($sNamespace = $el->getNamespace($sPrefix)) {
                     // TODO to add a namespace
                     $this->setAttribute($sPrefix . ':ns', 'null', $sNamespace);
                     // $this->setAttribute('xmlns:'.$sPrefix, $sNamespace);
                 } else {
                     unset($aResult[$iPrefix]);
                 }
             }
         }
         $this->setAttribute($sPrefixes, implode(' ', array_merge($aResult, $aTarget)));
     }
     if ($ext) {
         switch ($ext->getName(true)) {
             case 'include':
                 $ext->replace($el->getChildren());
                 break;
             case 'import':
                 $this->add($el->getChildren());
                 break;
             default:
                 $this->throwException(sprintf('Cannot import document in empty template with %s', $ext->asToken()));
         }
     } else {
         $this->shift($el->getChildren());
     }
 }
Example #11
0
 protected function simpleAsArray(dom\element $el)
 {
     $aResult = array();
     $sName = $this->buildName($el->getName(), $el->getNamespace());
     if (!$this->getRoot()->getCurrentElement(false)) {
         $this->buildNamespaces();
     }
     $aResult[] = '<' . $sName;
     $aResult[] = $this->parseAttributes();
     $aResult[] = '/>';
     return $aResult;
 }