Ejemplo n.º 1
0
 /**
  * doImport
  *
  * @return void
  */
 public function doImport()
 {
     $directory = $this->getDirectory();
     $array = array();
     if ($directory !== null) {
         foreach ((array) $directory as $dir) {
             $e = explode('.', $dir);
             // If they specified a specific yml file
             if (end($e) == 'yml') {
                 $array = array_merge($array, Doctrine_Parser::load($dir, $this->getFormat()));
                 // If they specified a directory
             } else {
                 if (is_dir($dir)) {
                     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);
                     foreach ($it as $file) {
                         $e = explode('.', $file->getFileName());
                         if (in_array(end($e), $this->getFormats())) {
                             $array = array_merge($array, Doctrine_Parser::load($file->getPathName(), $this->getFormat()));
                         }
                     }
                 }
             }
         }
     }
     $this->_loadData($array);
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->logSection('doctrine', 'generating model classes');
     $config = $this->getCliConfig();
     $this->_checkForPackageParameter($config['yaml_schema_path']);
     $tmpPath = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp';
     if (!file_exists($tmpPath)) {
         Doctrine_Lib::makeDirectories($tmpPath);
     }
     $plugins = $this->configuration->getPlugins();
     foreach ($this->configuration->getAllPluginPaths() as $plugin => $path) {
         if (!in_array($plugin, $plugins)) {
             continue;
         }
         $schemas = sfFinder::type('file')->name('*.yml')->in($path . '/config/doctrine');
         foreach ($schemas as $schema) {
             $tmpSchemaPath = $tmpPath . DIRECTORY_SEPARATOR . $plugin . '-' . basename($schema);
             $models = Doctrine_Parser::load($schema, 'yml');
             if (!isset($models['package'])) {
                 $models['package'] = $plugin . '.lib.model.doctrine';
                 $models['package_custom_path'] = $path . '/lib/model/doctrine';
             }
             Doctrine_Parser::dump($models, 'yml', $tmpSchemaPath);
         }
     }
     $options = array('generateBaseClasses' => true, 'generateTableClasses' => true, 'packagesPath' => sfConfig::get('sf_plugins_dir'), 'packagesPrefix' => 'Plugin', 'suffix' => '.class.php', 'baseClassesDirectory' => 'base', 'baseClassName' => 'sfDoctrineRecord');
     $options = array_merge($options, sfConfig::get('doctrine_model_builder_options', array()));
     $import = new Doctrine_Import_Schema();
     $import->setOptions($options);
     $import->importSchema(array($tmpPath, $config['yaml_schema_path']), 'yml', $config['models_path']);
 }
 public function testI18nExport()
 {
     try {
         $i = new I18nTestExport();
         $i->Translation['en']->title = 'english test';
         $i->Translation['fr']->title = 'french test';
         $i->test_object = new stdClass();
         $i->save();
         $data = new Doctrine_Data();
         $data->exportData('test.yml', 'yml', array('I18nTestExport', 'I18nTestExportTranslation'));
         $array = Doctrine_Parser::load('test.yml', 'yml');
         $this->assertTrue(!empty($array));
         $this->assertTrue(isset($array['I18nTestExport']['I18nTestExport_1']));
         $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_en']));
         $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_fr']));
         $i->Translation->delete();
         $i->delete();
         Doctrine_Core::loadData('test.yml');
         $q = Doctrine_Query::create()->from('I18nTestExport e')->leftJoin('e.Translation t');
         $results = $q->execute();
         $this->assertEqual(get_class($results[0]->test_object), 'stdClass');
         $this->pass();
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
     if (file_exists('test.yml')) {
         unlink('test.yml');
     }
 }
Ejemplo n.º 4
0
 /**
  * Do the parsing of the yaml files and return the final parsed array
  *
  * @return array $array
  */
 public function doParsing()
 {
     $recursiveMerge = Doctrine_Manager::getInstance()->getAttribute('recursive_merge_fixtures');
     $mergeFunction = $recursiveMerge === true ? 'array_merge_recursive' : 'array_merge';
     $directory = $this->getDirectory();
     $array = array();
     if ($directory !== null) {
         foreach ((array) $directory as $dir) {
             $e = explode('.', $dir);
             // If they specified a specific yml file
             if (end($e) == 'yml') {
                 $array = $mergeFunction($array, Doctrine_Parser::load($dir, $this->getFormat()));
                 // If they specified a directory
             } else {
                 if (is_dir($dir)) {
                     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);
                     foreach ($it as $file) {
                         $e = explode('.', $file->getFileName());
                         if (in_array(end($e), $this->getFormats())) {
                             $array = $mergeFunction($array, Doctrine_Parser::load($file->getPathName(), $this->getFormat()));
                         }
                     }
                 }
             }
         }
     }
     return $array;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $config = $this->getCliConfig();
     $pluginSchemaDirectories = glob(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'doctrine');
     $pluginSchemas = sfFinder::type('file')->name('*.yml')->in($pluginSchemaDirectories);
     $tmpPath = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp';
     if (!file_exists($tmpPath)) {
         Doctrine_Lib::makeDirectories($tmpPath);
     }
     foreach ($pluginSchemas as $schema) {
         $schema = str_replace('/', DIRECTORY_SEPARATOR, $schema);
         $plugin = str_replace(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR, '', $schema);
         $e = explode(DIRECTORY_SEPARATOR, $plugin);
         $plugin = $e[0];
         $name = basename($schema);
         $tmpSchemaPath = $tmpPath . DIRECTORY_SEPARATOR . $plugin . '-' . $name;
         $models = Doctrine_Parser::load($schema, 'yml');
         if (!isset($models['package'])) {
             $models['package'] = $plugin . '.lib.model.doctrine';
         }
         Doctrine_Parser::dump($models, 'yml', $tmpSchemaPath);
     }
     $import = new Doctrine_Import_Schema();
     $import->setOption('generateBaseClasses', true);
     $import->setOption('generateTableClasses', true);
     $import->setOption('packagesPath', sfConfig::get('sf_plugins_dir'));
     $import->setOption('packagesPrefix', 'Plugin');
     $import->setOption('suffix', '.class.php');
     $import->setOption('baseClassesDirectory', 'generated');
     $import->setOption('baseClassName', 'sfDoctrineRecord');
     $import->importSchema(array($tmpPath, $config['yaml_schema_path']), 'yml', $config['models_path']);
     $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('doctrine', 'Generated models successfully'))));
 }
Ejemplo n.º 6
0
    public function testI18nExport()
    {
        try {
            $i = new I18nTestExport();
            $i->Translation['en']->title = 'english test';
            $i->Translation['fr']->title = 'french test';
            $i->save();
            $i->free();

            $data = new Doctrine_Data();
            $data->exportData('test.yml', 'yml', array('I18nTestExport', 'I18nTestExportTranslation'));

            $array = Doctrine_Parser::load('test.yml', 'yml');

            $this->assertTrue( ! empty($array));
            $this->assertTrue(isset($array['I18nTestExport']['I18nTestExport_1']));
            $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_en']));
            $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_fr']));

            $this->pass();
        } catch (Exception $e) {
            $this->fail($e->getMessage());
        }

        if (file_exists('test.yml')) {
            unlink('test.yml');
        }
    }
Ejemplo n.º 7
0
 protected function _printResults($array)
 {
     $yaml = Doctrine_Parser::dump($array, 'yml');
     $lines = explode("\n", $yaml);
     unset($lines[0]);
     foreach ($lines as $yamlLine) {
         $line = trim($yamlLine);
         if ($line) {
             $this->notify($yamlLine);
         }
     }
 }
Ejemplo n.º 8
0
 protected function printResults($data)
 {
     $array = $data->toArray(true);
     $yaml = Doctrine_Parser::dump($array, 'yml');
     $lines = explode("\n", $yaml);
     unset($lines[0]);
     $lines[1] = $data->getTable()->getOption('name') . ':';
     foreach ($lines as $yamlLine) {
         $line = trim($yamlLine);
         if ($line) {
             $this->notify($yamlLine);
         }
     }
 }
 protected function loadModels()
 {
     // todo : fix this part to load model from the plugins ...
     $basePath = $this->generatorManager->getConfiguration()->getRootDir();
     $schemas = sfFinder::type('file')->name('*.yml')->in($basePath . '/config/doctrine');
     foreach ($schemas as $schema) {
         $data = Doctrine_Parser::load($schema, 'yml');
         $models = array();
         foreach ($data as $model => $definition) {
             try {
                 Doctrine::getTable($model)->getTableName();
                 $models[] = $model;
             } catch (Exception $e) {
             }
         }
         $this->models = $models;
     }
 }
Ejemplo n.º 10
0
 /**
  * exportSchema
  *
  * @param  string $schema 
  * @param  string $directory 
  * @return string $string of data in the specified format
  * @return void
  */
 public function exportSchema($schema, $format = 'yml', $directory = null, $models = array())
 {
     $array = $this->buildSchema($directory, $models);
     if (is_dir($schema)) {
         $schema = $schema . DIRECTORY_SEPARATOR . 'schema.' . $format;
     }
     return Doctrine_Parser::dump($array, $format, $schema);
 }
Ejemplo n.º 11
0
 /**
  * Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats
  *
  * @param string $type 
  * @param string $data 
  * @return void
  */
 public function importFrom($type, $data)
 {
     if ($type == 'array') {
         return $this->fromArray($data);
     } else {
         return $this->fromArray(Doctrine_Parser::load($data, $type));
     }
 }
 public function testLoadFromString()
 {
     $yml = "---\ntest: good job\ntest2: true\ntesting: <?php echo 'false'.\"\n\"; ?>\nw00t: not now\n";
     $array = Doctrine_Parser::load($yml, 'yml');
     $this->assertEqual($array, array('test' => 'good job', 'test2' => true, 'testing' => false, 'w00t' => 'not now'));
 }
Ejemplo n.º 13
0
    /**
     * Do the parsing of the yaml files and return the final parsed array
     *
     * @return array $array
     */
    public function doParsing()
    {
        $recursiveMerge = Doctrine_Manager::getInstance()->getAttribute(Doctrine_Core::ATTR_RECURSIVE_MERGE_FIXTURES);
        $mergeFunction = $recursiveMerge === true ? 'array_merge_recursive':'array_merge';
        $directory = $this->getDirectory();

        $array = array();

        if ($directory !== null) {
            foreach ((array) $directory as $dir) {
                $e = explode('.', $dir);

                // If they specified a specific yml file
                if (end($e) == 'yml') {
                    $array = $mergeFunction($array, Doctrine_Parser::load($dir, $this->getFormat()));
                // If they specified a directory
                } else if (is_dir($dir)) {
                    $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
                                                            RecursiveIteratorIterator::LEAVES_ONLY);
                    $filesOrdered = array();
                    foreach ($it as $file) {
                        $filesOrdered[] = $file;
                    }
                    // force correct order
                    natcasesort($filesOrdered);
                    foreach ($filesOrdered as $file) {
                        $e = explode('.', $file->getFileName());
                        if (in_array(end($e), $this->getFormats())) {
                            $array = $mergeFunction($array, Doctrine_Parser::load($file->getPathName(), $this->getFormat()));
                        }
                    }
                }
            }
        }

        return $array;
    }
Ejemplo n.º 14
0
 /**
  * dumpData
  *
  * Dump the prepared data to the fixtures files
  *
  * @param string $array 
  * @return void
  */
 public function dumpData(array $data)
 {
     $directory = $this->getDirectory();
     $format = $this->getFormat();
     if ($this->exportIndividualFiles()) {
         if (is_array($directory)) {
             throw new Doctrine_Data_Exception('You must specify a single path to a folder in order to export individual files.');
         } else {
             if (!is_dir($directory) && is_file($directory)) {
                 $directory = dirname($directory);
             }
         }
         foreach ($data as $className => $classData) {
             if (!empty($classData)) {
                 Doctrine_Parser::dump(array($className => $classData), $format, $directory . DIRECTORY_SEPARATOR . $className . '.' . $format);
             }
         }
     } else {
         if (is_dir($directory)) {
             $directory .= DIRECTORY_SEPARATOR . 'data.' . $format;
         }
         if (!empty($data)) {
             return Doctrine_Parser::dump($data, $format, $directory);
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * parseSchema
  *
  * A method to parse a Schema and translate it into a property array.
  * The function returns that property array.
  *
  * @param  string $schema   Path to the file containing the schema
  * @param  string $type     Format type of the schema we are parsing
  * @return array  $build    Built array of schema information
  */
 public function parseSchema($schema, $type)
 {
     $defaults = array('abstract' => false, 'className' => null, 'tableName' => null, 'connection' => null, 'relations' => array(), 'indexes' => array(), 'attributes' => array(), 'templates' => array(), 'actAs' => array(), 'options' => array(), 'package' => null, 'inheritance' => array(), 'detect_relations' => false);
     $array = Doctrine_Parser::load($schema, $type);
     // Loop over and build up all the global values and remove them from the array
     $globals = array();
     foreach ($array as $key => $value) {
         if (in_array($key, self::$_globalDefinitionKeys)) {
             unset($array[$key]);
             $globals[$key] = $value;
         }
     }
     // Merge the globals that aren't specifically set to each class
     foreach ($array as $className => $table) {
         $array[$className] = Doctrine_Lib::arrayDeepMerge($globals, $array[$className]);
     }
     $build = array();
     foreach ($array as $className => $table) {
         $table = (array) $table;
         $this->_validateSchemaElement('root', array_keys($table), $className);
         $columns = array();
         $className = isset($table['className']) ? (string) $table['className'] : (string) $className;
         if (isset($table['inheritance']['keyField']) || isset($table['inheritance']['keyValue'])) {
             $table['inheritance']['type'] = 'column_aggregation';
         }
         if (isset($table['tableName']) && $table['tableName']) {
             $tableName = $table['tableName'];
         } else {
             if (isset($table['inheritance']['type']) && $table['inheritance']['type'] == 'column_aggregation') {
                 $tableName = null;
             } else {
                 $tableName = Doctrine_Inflector::tableize($className);
             }
         }
         $connection = isset($table['connection']) ? $table['connection'] : 'current';
         $columns = isset($table['columns']) ? $table['columns'] : array();
         if (!empty($columns)) {
             foreach ($columns as $columnName => $field) {
                 // Support short syntax: my_column: integer(4)
                 if (!is_array($field)) {
                     $original = $field;
                     $field = array();
                     $field['type'] = $original;
                 }
                 $colDesc = array();
                 if (isset($field['name'])) {
                     $colDesc['name'] = $field['name'];
                 } else {
                     $colDesc['name'] = $columnName;
                 }
                 $this->_validateSchemaElement('column', array_keys($field), $className . '->columns->' . $colDesc['name']);
                 // Support short type(length) syntax: my_column: { type: integer(4) }
                 $e = explode('(', $field['type']);
                 if (isset($e[0]) && isset($e[1])) {
                     $colDesc['type'] = $e[0];
                     $value = substr($e[1], 0, strlen($e[1]) - 1);
                     $e = explode(',', $value);
                     $colDesc['length'] = $e[0];
                     if (isset($e[1]) && $e[1]) {
                         $colDesc['scale'] = $e[1];
                     }
                 } else {
                     $colDesc['type'] = isset($field['type']) ? (string) $field['type'] : null;
                     $colDesc['length'] = isset($field['length']) ? (int) $field['length'] : null;
                     $colDesc['length'] = isset($field['size']) ? (int) $field['size'] : $colDesc['length'];
                 }
                 $colDesc['fixed'] = isset($field['fixed']) ? (int) $field['fixed'] : null;
                 $colDesc['primary'] = isset($field['primary']) ? (bool) (isset($field['primary']) && $field['primary']) : null;
                 $colDesc['default'] = isset($field['default']) ? $field['default'] : null;
                 $colDesc['autoincrement'] = isset($field['autoincrement']) ? (bool) (isset($field['autoincrement']) && $field['autoincrement']) : null;
                 if (isset($field['sequence'])) {
                     if (true === $field['sequence']) {
                         $colDesc['sequence'] = $tableName;
                     } else {
                         $colDesc['sequence'] = (string) $field['sequence'];
                     }
                 } else {
                     $colDesc['sequence'] = null;
                 }
                 $colDesc['values'] = isset($field['values']) ? (array) $field['values'] : null;
                 // Include all the specified and valid validators in the colDesc
                 $validators = Doctrine_Manager::getInstance()->getValidators();
                 foreach ($validators as $validator) {
                     if (isset($field[$validator])) {
                         $colDesc[$validator] = $field[$validator];
                     }
                 }
                 $columns[(string) $columnName] = $colDesc;
             }
         }
         // Apply the default values
         foreach ($defaults as $key => $defaultValue) {
             if (isset($table[$key]) && !isset($build[$className][$key])) {
                 $build[$className][$key] = $table[$key];
             } else {
                 $build[$className][$key] = isset($build[$className][$key]) ? $build[$className][$key] : $defaultValue;
             }
         }
         $build[$className]['className'] = $className;
         $build[$className]['tableName'] = $tableName;
         $build[$className]['columns'] = $columns;
         // Make sure that anything else that is specified in the schema makes it to the final array
         $build[$className] = Doctrine_Lib::arrayDeepMerge($table, $build[$className]);
         // We need to keep track of the className for the connection
         $build[$className]['connectionClassName'] = $build[$className]['className'];
     }
     return $build;
 }
Ejemplo n.º 16
0
    /**
     * Constructor.
     *
     * @param Zikula_ServiceManager $serviceManager ServiceManager.
     * @param string                $themeName      Theme name.
     */
    public function __construct(Zikula_ServiceManager $serviceManager, $themeName)
    {
        // store our theme information
        $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($themeName));
        // prevents any case mismatch
        $themeName = $this->themeinfo['name'];

        foreach (array('name', 'directory', 'version', 'state', 'xhtml') as $key) {
            $this->$key = $this->themeinfo[$key];
        }

        parent::__construct($serviceManager);

        if ($this->themeinfo['i18n']) {
            ZLanguage::bindThemeDomain($this->name);
            // property for {gt} template plugin to detect language domain
            $this->domain = ZLanguage::getThemeDomain($this->name);
        } else {
            $this->domain = null;
        }

        EventUtil::attachCustomHandlers("themes/$themeName/lib/$themeName/EventHandlers");
        if (is_readable("themes/$themeName/templates/overrides.yml")) {
            $this->eventManager->attach('zikula_view.template_override', array($this, '_templateOverride'), 0);
            $this->_overrideMap = Doctrine_Parser::load("themes/$themeName/templates/overrides.yml", 'yml');
        }

        $event = new Zikula_Event('theme.preinit', $this);
        $this->eventManager->notify($event);

        // change some base settings from our parent class
        // template compilation
        $this->compile_dir   = CacheUtil::getLocalDir('Theme_compiled');
        $this->compile_check = ModUtil::getVar('Theme', 'compile_check');
        $this->force_compile = ModUtil::getVar('Theme', 'force_compile');
        // template caching
        $this->cache_dir = CacheUtil::getLocalDir('Theme_cache');
        $this->caching   = (int)ModUtil::getVar('Theme', 'enablecache');
        //if ($this->caching) {
        //    $this->cache_modified_check = true;
        //}

        // if caching and is not an admin controller
        if ($this->caching && strpos($this->type, 'admin') !== 0) {
            $modulesnocache = explode(',', ModUtil::getVar('Theme', 'modulesnocache'));
            if (in_array($this->toplevelmodule, $modulesnocache)) {
                $this->caching = Zikula_View::CACHE_DISABLED;
            }
        } else {
            $this->caching = Zikula_View::CACHE_DISABLED;
        }

        // halt caching for write operations to prevent strange things happening
        if (isset($_POST) && count($_POST) != 0) {
            $this->caching = Zikula_View::CACHE_DISABLED;
        }
        // and also for GET operations with csrftoken/authkey
        if (isset($_GET['csrftoken']) || isset($_GET['authkey'])) {
            $this->caching = Zikula_View::CACHE_DISABLED;
        }

        $this->cache_lifetime = ModUtil::getVar('Theme', 'cache_lifetime');

        // assign all our base template variables
        $this->_base_vars();

        // define the plugin directories
        $this->_plugin_dirs();

        // load the theme configuration
        $this->load_config();

        // check for cached output
        // turn on caching, check for cached output and then disable caching
        // to prevent blocks from being cached
        if ($this->caching && $this->is_cached($this->themeconfig['page'], $this->cache_id)) {
            $this->display($this->themeconfig['page'], $this->cache_id);
            System::shutdown();
        }

        // register page vars output filter
        $this->load_filter('output', 'pagevars');

        // register short urls output filter
        if (System::getVar('shorturls')) {
            $this->load_filter('output', 'shorturls');
        }

        // register trim whitespace output filter if requried
        if (ModUtil::getVar('Theme', 'trimwhitespace')) {
            $this->load_filter('output', 'trimwhitespace');
        }

        $event = new Zikula_Event('theme.init', $this);
        $this->eventManager->notify($event);

        // Start the output buffering to capture module output
        ob_start();
    }
 public function getFormatData($format)
 {
     $method = 'get' . ucfirst($format) . 'FormatData';
     if (method_exists($this->getContentTypeClassName(), $method)) {
         return $this->getRecord()->{$method}();
     } else {
         if (method_exists($this, $method)) {
             $data = $this->{$method}();
         } else {
             $data = $this->getDefaultFormatData();
         }
     }
     return Doctrine_Parser::dump($this->{$method}(), $format);
 }
 protected function generateYaml($schemaPath, $directory = null, $models = array(), $modelLoading = null)
 {
     $currentProjectModels = (array) sfYaml::load($schemaPath);
     $export = new Doctrine_Export_Schema();
     $newProjectModels = $export->buildSchema($directory, $models, $modelLoading);
     $projectModels = array_merge($currentProjectModels, $newProjectModels);
     if (is_dir($schemaPath)) {
         $schemaPath = $schemaPath . DIRECTORY_SEPARATOR . 'schema.yml';
     }
     return Doctrine_Parser::dump($projectModels, 'yml', $schemaPath);
 }
Ejemplo n.º 19
0
 /**
  * Setup of handlers.
  *
  * @return void
  */
 public function setup()
 {
     $this->overrideMap = Doctrine_Parser::load('config/template_overrides.yml', 'yml');
 }
Ejemplo n.º 20
0
 /**
  * parseSchema
  *
  * A method to parse a Schema and translate it into a property array.
  * The function returns that property array.
  *
  * @param  string $schema   Path to the file containing the schema
  * @return array  $build    Built array of schema information
  */
 public function parseSchema($schema, $type)
 {
     $array = Doctrine_Parser::load($schema, $type);
     $build = array();
     foreach ($array as $className => $table) {
         $columns = array();
         $className = isset($table['className']) ? (string) $table['className'] : (string) $className;
         if (isset($table['tableName']) && $table['tableName']) {
             $tableName = $table['tableName'];
         } else {
             if (isset($table['inheritance']['extends']) && isset($table['inheritance']['extends']['keyType']) && isset($table['inheritance']['extends']['keyValue'])) {
                 $tableName = null;
             } else {
                 $tableName = Doctrine::tableize($className);
             }
         }
         $columns = isset($table['columns']) ? $table['columns'] : array();
         $columns = isset($table['fields']) ? $table['fields'] : $columns;
         if (!empty($columns)) {
             foreach ($columns as $columnName => $field) {
                 $colDesc = array();
                 $colDesc['name'] = $columnName;
                 $e = explode('(', $field['type']);
                 if (isset($e[0]) && isset($e[1])) {
                     $colDesc['type'] = $e[0];
                     $colDesc['length'] = substr($e[1], 0, strlen($e[1]) - 1);
                 } else {
                     $colDesc['type'] = isset($field['type']) ? (string) $field['type'] : null;
                     $colDesc['length'] = isset($field['length']) ? (int) $field['length'] : null;
                     $colDesc['length'] = isset($field['size']) ? (int) $field['size'] : $colDesc['length'];
                 }
                 $colDesc['ptype'] = isset($field['ptype']) ? (string) $field['ptype'] : (string) $colDesc['type'];
                 $colDesc['fixed'] = isset($field['fixed']) ? (int) $field['fixed'] : null;
                 $colDesc['primary'] = isset($field['primary']) ? (bool) (isset($field['primary']) && $field['primary']) : null;
                 $colDesc['default'] = isset($field['default']) ? $field['default'] : null;
                 $colDesc['autoincrement'] = isset($field['autoincrement']) ? (bool) (isset($field['autoincrement']) && $field['autoincrement']) : null;
                 $colDesc['autoincrement'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']) : $colDesc['autoincrement'];
                 $colDesc['sequence'] = isset($field['sequence']) ? (string) $field['sequence'] : null;
                 $colDesc['values'] = isset($field['values']) ? (array) $field['values'] : null;
                 $validators = Doctrine_Lib::getValidators();
                 foreach ($validators as $validator) {
                     if (isset($field[$validator])) {
                         $colDesc[$validator] = $field[$validator];
                     }
                 }
                 $columns[(string) $colDesc['name']] = $colDesc;
             }
         }
         $build[$className]['connection'] = isset($table['connection']) ? $table['connection'] : null;
         $build[$className]['className'] = $className;
         $build[$className]['tableName'] = $tableName;
         $build[$className]['columns'] = $columns;
         $build[$className]['relations'] = isset($table['relations']) ? $table['relations'] : array();
         $build[$className]['indexes'] = isset($table['indexes']) ? $table['indexes'] : array();
         $build[$className]['attributes'] = isset($table['attributes']) ? $table['attributes'] : array();
         $build[$className]['templates'] = isset($table['templates']) ? $table['templates'] : array();
         $build[$className]['actAs'] = isset($table['actAs']) ? $table['actAs'] : array();
         $build[$className]['options'] = isset($table['options']) ? $table['options'] : array();
         $build[$className]['package'] = isset($table['package']) ? $table['package'] : null;
         if (isset($table['inheritance'])) {
             $build[$className]['inheritance'] = $table['inheritance'];
         }
     }
     return $build;
 }