예제 #1
0
 /**
  * The element handler functions for the XML parser
  * 
  * @link  http://www.php.net/manual/en/function.xml-set-element-handler.php
  */
 protected function xmlStartTag($parser, $name, $attribs)
 {
     # convert attributes to phpType
     foreach ($attribs as &$value) {
         $value = self::phpize($value);
     }
     switch ($name) {
         case 'writer':
             if (isset($attribs['format']) === false) {
                 throw new EngineException('Writter Tag Missing Format');
             }
             if (isset($attribs['platform']) === false) {
                 throw new EngineException('Writer Tag Missing Platform');
             }
             $platform = $attribs['platform'];
             $format = $attribs['format'];
             unset($attribs['format']);
             unset($attribs['platform']);
             $this->builder->addWriter($platform, $format, $attribs);
             break;
         case 'schema':
             if (isset($attribs['name']) === false) {
                 throw new EngineException('Schema Tag Missing Name');
             }
             $this->builder->addSchema($attribs['name'], $attribs);
             break;
         case 'table':
             if (isset($attribs['name']) === false) {
                 throw new EngineException('Table Tag Missing Name');
             }
             $this->builder->addTable($attribs['name'], $attribs);
             break;
         case 'column':
             if (isset($attribs['name']) === false) {
                 throw new EngineException('Column Tag Missing Name');
             }
             $this->builder->addColumn($attribs['name'], $attribs);
             break;
         case 'datatype':
             if (isset($attribs['name']) === false) {
                 throw new EngineException('Datatype Tag Missing Name');
             }
             $this->builder->addType($attribs['name'], $attribs);
             break;
         case 'option':
             if (isset($attribs['name']) === false) {
                 throw new EngineException('Have Type Option Tag Missing Name Attribute');
             }
             if (isset($attribs['value']) === false) {
                 throw new EngineException('Have Type Option Tag Missing Value Attribute');
             }
             $this->builder->setTypeOption($attribs['name'], $attribs['value']);
             break;
         case 'foreign-key':
             if (isset($attribs['name']) === false) {
                 throw new EngineException('Foreign-key must have a name unique name try foreignTable.foriegnColumn');
             }
             $this->builder->addForeignKey($attribs['name'], $attribs);
             break;
         case 'alternate':
         case 'pick':
         case 'random':
         case 'when':
         case 'swap':
             $this->builder->addSelector($name, $attribs);
             break;
         default:
             throw new EngineException(sprintf('Tag name %s unknown', $name));
     }
 }