当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Core::filterInvalidModels方法代码示例

本文整理汇总了PHP中Doctrine_Core::filterInvalidModels方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Core::filterInvalidModels方法的具体用法?PHP Doctrine_Core::filterInvalidModels怎么用?PHP Doctrine_Core::filterInvalidModels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Core的用法示例。


在下文中一共展示了Doctrine_Core::filterInvalidModels方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadModels

 /**
  * Loads all model classes and returns an array of model names.
  * 
  * @return array An array of model names
  */
 protected function loadModels()
 {
     Doctrine_Core::loadModels($this->configuration->getModelDirs());
     $models = Doctrine_Core::getLoadedModels();
     $models = Doctrine_Core::initializeModels($models);
     $models = Doctrine_Core::filterInvalidModels($models);
     return $models;
 }
开发者ID:cbsistem,项目名称:appflower_studio_playground,代码行数:13,代码来源:sfTaskExtraDoctrineBaseTask.class.php

示例2: exportClassesSql

 public function exportClassesSql(array $classes)
 {
     $models = Doctrine_Core::filterInvalidModels($classes);
     $sql = array();
     foreach ($models as $name) {
         $record = new $name();
         $table = $record->getTable();
         //$parents = $table->getOption('joinedParents');
         // Don't export the tables with attribute EXPORT_NONE'
         if ($table->getAttribute(Doctrine_Core::ATTR_EXPORT) === Doctrine_Core::EXPORT_NONE) {
             continue;
         }
         $data = $table->getExportableFormat();
         $data['options']['inheritance'] = array();
         $parents = array("Doctrine_Record", "sfPostgresDoctrineRecord", "sfDoctrineRecord", "BaseDoctrineRecord");
         if (get_parent_class($name) != $name && strpos($name, 'Base') === false) {
             if (strpos(get_parent_class($name), 'Base') === false) {
                 if (!in_array(get_parent_class($name), $parents)) {
                     $data['options']['inheritance'] = get_parent_class($name);
                 }
             } else {
                 if (get_parent_class(get_parent_class($name)) != get_parent_class($name) && !in_array(get_parent_class(get_parent_class($name)), $parents)) {
                     $data['options']['inheritance'] = get_parent_class(get_parent_class($name));
                 }
             }
         }
         if (!empty($data['options']['inheritance'])) {
             $dataTmp = $table->getConnection()->getTable($data['options']['inheritance'])->getExportableFormat();
             foreach ($dataTmp['columns'] as $name => $column) {
                 if (isset($data['columns'][$name]) && isset($data['columns'][$name]['primary']) && $data['columns'][$name]['primary'] != 1) {
                     unset($data['columns'][$name]);
                 }
             }
         } else {
             unset($data['options']['inheritance']);
         }
         $query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
         if (is_array($query)) {
             $sql = array_merge($sql, $query);
         } else {
             $sql[] = $query;
         }
         if ($table->getAttribute(Doctrine_Core::ATTR_EXPORT) & Doctrine_Core::EXPORT_PLUGINS) {
             $sql = array_merge($sql, $this->exportGeneratorsSql($table));
         }
         // DC-474: Remove dummy $record from repository to not pollute it during export
         $table->getRepository()->evict($record->getOid());
         unset($record);
     }
     $sql = array_unique($sql);
     rsort($sql);
     return $sql;
 }
开发者ID:jamespaulmuir,项目名称:cotinga,代码行数:53,代码来源:Pgsql.php

示例3: testAggressiveModelLoading

 public function testAggressiveModelLoading()
 {
     $path = realpath('ModelLoadingTest/Aggressive');
     $models = Doctrine_Core::loadModels($path, Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
     // Ensure the correct model names were returned
     $this->assertTrue(isset($models['AggressiveModelLoadingUser']) && $models['AggressiveModelLoadingUser'] == 'AggressiveModelLoadingUser');
     $this->assertTrue(isset($models['AggressiveModelLoadingProfile']) && $models['AggressiveModelLoadingProfile'] == 'AggressiveModelLoadingProfile');
     $this->assertTrue(isset($models['AggressiveModelLoadingContact']) && $models['AggressiveModelLoadingContact'] == 'AggressiveModelLoadingContact');
     // Make sure it does not include the base classes
     $this->assertTrue(!isset($models['BaseAggressiveModelLoadingUser']));
     $filteredModels = Doctrine_Core::filterInvalidModels($models);
     // Make sure filterInvalidModels filters out base abstract classes
     $this->assertTrue(!isset($models['BaseAggressiveModelLoadingUser']));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:14,代码来源:BaseTestCase.php

示例4: exportSql

 /**
  * exportSql
  * returns the sql for exporting Doctrine_Record classes to a schema
  *
  * if the directory parameter is given this method first iterates
  * recursively trhough the given directory in order to find any model classes
  *
  * Then it iterates through all declared classes and creates tables for the ones
  * that extend Doctrine_Record and are not abstract classes
  *
  * @throws Doctrine_Connection_Exception    if some error other than Doctrine_Core::ERR_ALREADY_EXISTS
  *                                          occurred during the create table operation
  * @param string $directory     optional directory parameter
  * @return void
  */
 public function exportSql($directory = null)
 {
     if ($directory !== null) {
         $models = Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels($directory));
     } else {
         $models = Doctrine_Core::getLoadedModels();
     }
     return $this->exportSortedClassesSql($models, false);
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:24,代码来源:Export.php

示例5: generateMigrationsFromModels

 /**
  * Generate a set of migrations from a set of models
  *
  * @param  string $modelsPath    Path to models
  * @param  string $modelLoading  What type of model loading to use when loading the models
  * @return boolean
  */
 public function generateMigrationsFromModels($modelsPath = null, $modelLoading = null)
 {
     if ($modelsPath !== null) {
         $models = Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels($modelsPath, $modelLoading));
     } else {
         $models = Doctrine_Core::getLoadedModels();
     }
     $models = Doctrine_Core::initializeModels($models);
     $foreignKeys = array();
     foreach ($models as $model) {
         $table = Doctrine_Core::getTable($model);
         if ($table->getTableName() !== $this->migration->getTableName()) {
             $export = $table->getExportableFormat();
             $foreignKeys[$export['tableName']] = $export['options']['foreignKeys'];
             $up = $this->buildCreateTable($export);
             $down = $this->buildDropTable($export);
             $className = 'Add' . Doctrine_Inflector::classify($export['tableName']);
             $this->generateMigrationClass($className, array(), $up, $down);
         }
     }
     if (!empty($foreignKeys)) {
         $className = 'AddFks';
         $up = array();
         $down = array();
         foreach ($foreignKeys as $tableName => $definitions) {
             $tableForeignKeyNames[$tableName] = array();
             foreach ($definitions as $definition) {
                 $up[] = $this->buildCreateForeignKey($tableName, $definition);
                 $down[] = $this->buildDropForeignKey($tableName, $definition);
             }
         }
         $up = implode("\n", $up);
         $down = implode("\n", $down);
         if ($up || $down) {
             $this->generateMigrationClass($className, array(), $up, $down);
         }
     }
     return true;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:46,代码来源:Builder.php

示例6: loadModels

 /**
  * Loads all Doctrine builders.
  */
 protected function loadModels()
 {
     Doctrine_Core::loadModels($this->generatorManager->getConfiguration()->getModelDirs());
     $models = Doctrine_Core::getLoadedModels();
     $models = Doctrine_Core::initializeModels($models);
     $models = Doctrine_Core::filterInvalidModels($models);
     $this->models = $this->filterModels($models);
     return $this->models;
 }
开发者ID:cuongnv540,项目名称:jobeet,代码行数:12,代码来源:sfDoctrineFormGenerator.class.php

示例7: purge

 /**
  * purge
  * 
  * Purge all data for loaded models or for the passed array of Doctrine_Records
  *
  * @param string $models 
  * @return void
  */
 public function purge($models = null)
 {
     if ($models) {
         $models = Doctrine_Core::filterInvalidModels($models);
     } else {
         $models = Doctrine_Core::getLoadedModels();
     }
     $connections = array();
     foreach ($models as $model) {
         $connections[Doctrine_Core::getTable($model)->getConnection()->getName()][] = $model;
     }
     foreach ($connections as $connection => $models) {
         $models = Doctrine_Manager::getInstance()->getConnection($connection)->unitOfWork->buildFlushTree($models);
         $models = array_reverse($models);
         foreach ($models as $model) {
             Doctrine_Core::getTable($model)->createQuery()->delete()->execute();
         }
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:27,代码来源:Data.php

示例8: buildSchema

 /**
  * buildSchema
  *
  * Build schema array that can be dumped to file
  *
  * @param string $directory  The directory of models to build the schema from
  * @param array $models      The array of model names to build the schema for
  * @param integer $modelLoading The model loading strategy to use to load the models from the passed directory
  * @return void
  */
 public function buildSchema($directory = null, $models = array(), $modelLoading = null)
 {
     if ($directory !== null) {
         $loadedModels = Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels($directory, $modelLoading));
     } else {
         $loadedModels = Doctrine_Core::getLoadedModels();
     }
     $array = array();
     $parent = new ReflectionClass('Doctrine_Record');
     $sql = array();
     $fks = array();
     $behaviors = array();
     foreach (sfProjectConfiguration::getActive()->getPluginPaths() as $path) {
         if (strpos($path, 'sfPostgresDoctrinePlugin') !== false) {
             $behaviors = sfYaml::load(sfConfig::get('sf_config_dir') . DIRECTORY_SEPARATOR . 'plugins/sfPostgresDoctrinePlugin' . DIRECTORY_SEPARATOR . 'behaviors.yml');
             break;
         }
     }
     // we iterate through the diff of previously declared classes
     // and currently declared classes
     foreach ($loadedModels as $className) {
         if (!empty($models) && !in_array($className, $models)) {
             continue;
         }
         $recordTable = Doctrine_Core::getTable($className);
         $data = $recordTable->getExportableFormat();
         $table = array();
         $table['connection'] = $recordTable->getConnection()->getName();
         $remove = array('ptype', 'ntype', 'alltypes');
         // Fix explicit length in schema, concat it to type in this format: type(length)
         $columns = array_keys($data['columns']);
         $tb = array();
         foreach ((array) $behaviors as $name => $behavior) {
             $i = false;
             if (isset($behavior['tableName'])) {
                 if (is_array($behavior['tableName'])) {
                     if (in_array($data['tableName'], $behavior['tableName'])) {
                         $i = true;
                     } else {
                         foreach ($behavior['tableName'] as $tName) {
                             if (preg_match("/^" . str_replace(array(".", "*"), array("\\.", ".+?"), $tName) . "\$/i", $data['tableName'], $m)) {
                                 $i = true;
                                 break;
                             }
                         }
                     }
                 } else {
                     if ($behavior['tableName'] == 'all' || $behavior['tableName'] == $data['tableName'] || preg_match("/^" . str_replace(array(".", "*"), array("\\.", ".+?"), $behavior['tableName']) . "\$/i", $data['tableName'], $m)) {
                         $i = true;
                     }
                 }
                 if ($i && isset($behavior['exclusions'])) {
                     if (is_array($behavior['exclusions'])) {
                         foreach ($behavior['exclusions'] as $tName) {
                             if (preg_match("/^" . str_replace(array(".", "*"), array("\\.", ".*?"), $tName) . "\$/i", $data['tableName'], $m)) {
                                 $i = false;
                                 break;
                             }
                         }
                     } else {
                         if (preg_match("/^" . str_replace(array(".", "*"), array("\\.", ".*?"), $behavior['exclusions']) . "\$/i", $data['tableName'], $m)) {
                             $i = false;
                         }
                     }
                 }
                 $cantHave = array();
                 $mustHave = array();
                 if ($i) {
                     if (isset($behavior['condition']) && count($behavior['condition']) > 0 && isset($behavior['condition']['columns'])) {
                         if (is_array($behavior['condition']['columns'])) {
                             if (count($behavior['condition']['columns']) > 0) {
                                 foreach ($behavior['condition']['columns'] as $column) {
                                     if (preg_match('/^!/i', $column, $m)) {
                                         $cantHave[] = str_replace("!", "", $column);
                                     } else {
                                         $mustHave[] = $column;
                                     }
                                 }
                                 $isOK = true;
                                 if (count($mustHave > 0)) {
                                     if (count(array_intersect($columns, $mustHave)) != count($mustHave)) {
                                         $isOK = false;
                                     }
                                 }
                                 if ($isOK && count($cantHave > 0)) {
                                     if (count(array_intersect($columns, $cantHave)) > 0) {
                                         $isOK = false;
                                     }
                                 }
                                 if ($isOK) {
//.........这里部分代码省略.........
开发者ID:jamespaulmuir,项目名称:cotinga,代码行数:101,代码来源:Schema.php

示例9: buildSchema

    /**
     * buildSchema
     *
     * Build schema array that can be dumped to file
     *
     * @param string $directory  The directory of models to build the schema from
     * @param array $models      The array of model names to build the schema for
     * @param integer $modelLoading The model loading strategy to use to load the models from the passed directory
     * @return void
     */
    public function buildSchema($directory = null, $models = array(), $modelLoading = null)
    {
        if ($directory !== null) {
            $loadedModels = Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels($directory, $modelLoading));
        } else {
            $loadedModels = Doctrine_Core::getLoadedModels();
        }

        $array = array();

        $parent = new ReflectionClass('Doctrine_Record');

        $sql = array();
        $fks = array();

        // we iterate through the diff of previously declared classes
        // and currently declared classes
        foreach ($loadedModels as $className) {
            if ( ! empty($models) && !in_array($className, $models)) {
                continue;
            }

            $recordTable = Doctrine_Core::getTable($className);

            $data = $recordTable->getExportableFormat();

            $table = array();
            $table['connection'] = $recordTable->getConnection()->getName();
            $remove = array('ptype', 'ntype', 'alltypes');
            // Fix explicit length in schema, concat it to type in this format: type(length)
            foreach ($data['columns'] AS $name => $column) {
                if (isset($column['length']) && $column['length'] && isset($column['scale']) && $column['scale']) {
                    $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ', ' . $column['scale'] . ')';
                    unset($data['columns'][$name]['length'], $data['columns'][$name]['scale']);
                } else {
                    $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')';
                    unset($data['columns'][$name]['length']);
                }
                // Strip out schema information which is not necessary to be dumped to the yaml schema file
                foreach ($remove as $value) {
                    if (isset($data['columns'][$name][$value])) {
                        unset($data['columns'][$name][$value]);
                    }
                }

                // If type is the only property of the column then lets abbreviate the syntax
                // columns: { name: string(255) }
                if (count($data['columns'][$name]) === 1 && isset($data['columns'][$name]['type'])) {
                    $type = $data['columns'][$name]['type'];
                    unset($data['columns'][$name]);
                    $data['columns'][$name] = $type;
                }
            }
            $table['tableName'] = $data['tableName'];
            $table['columns'] = $data['columns'];

            $relations = $recordTable->getRelations();
            foreach ($relations as $key => $relation) {
                $relationData = $relation->toArray();

                $relationKey = $relationData['alias'];

                if (isset($relationData['refTable']) && $relationData['refTable']) {
                    $table['relations'][$relationKey]['refClass'] = $relationData['refTable']->getComponentName();
                }

                if (isset($relationData['class']) && $relationData['class'] && $relation['class'] != $relationKey) {
                    $table['relations'][$relationKey]['class'] = $relationData['class'];
                }

                $table['relations'][$relationKey]['local'] = $relationData['local'];
                $table['relations'][$relationKey]['foreign'] = $relationData['foreign'];

                if ($relationData['type'] === Doctrine_Relation::ONE) {
                    $table['relations'][$relationKey]['type'] = 'one';
                } else if ($relationData['type'] === Doctrine_Relation::MANY) {
                    $table['relations'][$relationKey]['type'] = 'many';
                } else {
                    $table['relations'][$relationKey]['type'] = 'one';
                }
            }

            $array[$className] = $table;
        }

        return $array;
    }
开发者ID:nationalfield,项目名称:symfony,代码行数:97,代码来源:Schema.php

示例10: loadModels

 /**
  * Load builders
  * 
  * @return  array   Loaded models
  */
 protected function loadModels()
 {
     Doctrine_Core::loadModels(array(sfConfig::get('sf_lib_dir') . '/model'));
     $this->models = $this->filterModels(Doctrine_Core::filterInvalidModels(Doctrine_Core::initializeModels(Doctrine_Core::getLoadedModels())));
     return $this->models;
 }
开发者ID:relo-san,项目名称:dinDoctrineExtraPlugin,代码行数:11,代码来源:dinDoctrineFormFilterGenerator.php


注:本文中的Doctrine_Core::filterInvalidModels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。