Source for file Yml.php

Documentation is available at Yml.php

  1. <?php
  2. /*
  3.  * $Id: Yml.php 1838 2007-06-26 00:58:21Z nicobn $
  4.  *
  5.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  *
  17.  * This software consists of voluntary contributions made by many individuals
  18.  * and is licensed under the LGPL. For more information, see
  19.  * <http://www.phpdoctrine.com>.
  20.  */
  21.  
  22. /**
  23.  * class Doctrine_Import_Schema_Yml
  24.  *
  25.  * Different methods to import a YML schema. The logic behind using two different
  26.  * methods is simple. Some people will like the idea of producing Doctrine_Record
  27.  * objects directly, which is totally fine. But in fast and growing application,
  28.  * table definitions tend to be a little bit more volatile. importArr() can be used
  29.  * to output a table definition in a PHP file. This file can then be stored
  30.  * independantly from the object itself.
  31.  *
  32.  * @package     Doctrine
  33.  * @category    Object Relational Mapping
  34.  * @link        www.phpdoctrine.com
  35.  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
  36.  * @version     $Revision: 1838 $
  37.  * @author      Nicolas BĂ©rard-Nault <nicobn@gmail.com>
  38.  * @author      Jonathan H. Wage <jonwage@gmail.com>
  39.  */
  40. {
  41.     /**
  42.      * parse
  43.      *
  44.      * @param string $schema 
  45.      * @return void 
  46.      */
  47.     public function parse($schema)
  48.     {
  49.         if (!is_readable($schema)) {
  50.             throw new Doctrine_Import_Exception('Could not read schema file '$schema);
  51.         }
  52.  
  53.         return array();
  54.     }
  55.     
  56.     /**
  57.      * parseSchema
  58.      *
  59.      * A method to parse a Yml Schema and translate it into a property array.
  60.      * The function returns that property array.
  61.      *
  62.      * @param  string $schema   Path to the file containing the XML schema
  63.      * @return array 
  64.      */
  65.     public function parseSchema($schema)
  66.     
  67.         $array $this->parse($schema);
  68.           
  69.         $tables array();
  70.         
  71.         // Not working yet
  72.         /*
  73.         // Go through all tables...
  74.         foreach ($array['table'] as $table) {
  75.             // Go through all columns... 
  76.             foreach ($table['declaration']['field'] as $field) {
  77.                 $colDesc = array(
  78.                     'name'      => (string) $field['name'],
  79.                     'type'      => (string) $field['type'],
  80.                     'ptype'     => (string) $field['type'],
  81.                     'length'    => (int) $field['length'],
  82.                     'fixed'     => (int) $field['fixed'],
  83.                     'unsigned'  => (bool) $field['unsigned'],
  84.                     'primary'   => (bool) (isset($field['primary']) && $field['primary']),
  85.                     'default'   => (string) $field['default'],
  86.                     'notnull'   => (bool) (isset($field['notnull']) && $field['notnull']),
  87.                     'autoinc'   => (bool) (isset($field['autoincrement']) && $field['autoincrement']),
  88.                 );
  89.             
  90.                 $columns[(string) $field['name']] = $colDesc;
  91.             }
  92.             
  93.             $tables[(string) $table['name']] = $columns;
  94.         }
  95.         */
  96.         
  97.         return $tables;
  98.     }
  99. }