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


PHP Doctrine::filterInvalidModels方法代码示例

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


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

示例1: loadModels

 /**
  * Provides a array with all model names
  *
  * @return array
  */
 public function loadModels()
 {
     $models = Doctrine::loadModels($this->modelDir, Doctrine::MODEL_LOADING_CONSERVATIVE);
     $models = Doctrine::initializeModels($models);
     $this->models = Doctrine::filterInvalidModels($models);
     return $this->models;
 }
开发者ID:yuxw75,项目名称:Surrogate,代码行数:12,代码来源:doctrineGraphvizTaskTest.php

示例2: testAggressiveModelLoading

 public function testAggressiveModelLoading()
 {
     $path = realpath('ModelLoadingTest/Aggressive');
     $models = Doctrine::loadModels($path, Doctrine::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::filterInvalidModels($models);
     // Make sure filterInvalidModels filters out base abstract classes
     $this->assertTrue(!isset($models['BaseAggressiveModelLoadingUser']));
 }
开发者ID:swk,项目名称:bluebox,代码行数:14,代码来源:BaseTestCase.php

示例3: buildSchema

 /**
  * buildSchema
  * 
  * Build schema array that can be dumped to file
  *
  * @param string $directory 
  * @return void
  */
 public function buildSchema($directory = null, $models = array())
 {
     if ($directory !== null) {
         $loadedModels = Doctrine::filterInvalidModels(Doctrine::loadModels($directory));
     } else {
         $loadedModels = Doctrine::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::getTable($className);
         $data = $recordTable->getExportableFormat();
         $table = array();
         $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:JimmyVB,项目名称:Symfony-v1.2,代码行数:80,代码来源:Schema.php

示例4: 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 = array())
 {
     $models = Doctrine::filterInvalidModels($models);
     foreach ($models as $model) {
         $model = new $model();
         $model->getTable()->createQuery()->delete($model)->execute();
     }
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:16,代码来源:Data.php

示例5: loadModels

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

示例6: 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::filterInvalidModels($models);
     } else {
         $models = Doctrine::getLoadedModels();
     }
     foreach ($models as $model) {
         $model = new $model();
         $model->getTable()->createQuery()->delete($model)->execute();
     }
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:20,代码来源:Data.php

示例7: generateMigrationsFromModels

 /**
  * generateMigrationsFromModels
  *
  * @param string $modelsPath 
  * @return void
  */
 public function generateMigrationsFromModels($modelsPath = null, $modelLoading = null)
 {
     if ($modelsPath !== null) {
         $models = Doctrine::filterInvalidModels(Doctrine::loadModels($modelsPath, $modelLoading));
     } else {
         $models = Doctrine::getLoadedModels();
     }
     $models = Doctrine::initializeModels($models);
     $foreignKeys = array();
     foreach ($models as $model) {
         $export = Doctrine::getTable($model)->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 = 'ApplyForeignKeyConstraints';
         $up = '';
         $down = '';
         foreach ($foreignKeys as $tableName => $definitions) {
             $tableForeignKeyNames[$tableName] = array();
             foreach ($definitions as $definition) {
                 $definition['name'] = $tableName . '_' . implode('_', (array) $definition['local']);
                 $up .= $this->buildCreateForeignKey($tableName, $definition);
                 $down .= $this->buildDropForeignKey($tableName, $definition);
             }
         }
         $this->generateMigrationClass($className, array(), $up, $down);
     }
     return true;
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:39,代码来源:Builder.php

示例8: 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::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::filterInvalidModels(Doctrine::loadModels($directory));
     } else {
         $models = Doctrine::getLoadedModels();
     }
     return $this->exportSortedClassesSql($models, false);
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:24,代码来源:Export.php

示例9: 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::filterInvalidModels(Doctrine::loadModels($modelsPath, $modelLoading));
     } else {
         $models = Doctrine::getLoadedModels();
     }
     $models = Doctrine::initializeModels($models);
     $foreignKeys = array();
     foreach ($models as $model) {
         $table = Doctrine::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:darkcolonist,项目名称:kohana234-doctrine115,代码行数:46,代码来源:Builder.php

示例10: dirname

/*
 * This file is part of sfDoctrineGraphvizPlugin
 * (c) 2009 David PHAM-VAN
 * (c) 2009 Dejan Spasic <spasic.dejan@yahoo.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../../bootstrap.php';
require_once dirname(__FILE__) . '/../../../../lib/generator/doctrineGraphvizMcdGenerator.class.php';
// path to model directory
$modelDir = dirname(__FILE__) . '/../../../_files/model';
// retrieve modelnames
$modelNames = Doctrine::loadModels($modelDir, Doctrine::MODEL_LOADING_CONSERVATIVE);
$modelNames = Doctrine::initializeModels($modelNames);
$modelNames = Doctrine::filterInvalidModels($modelNames);
$subject = new doctrineGraphvizMcdGenerator();
$t = new lime_test(8, new lime_output_color());
$t->ok("" === $subject->getBuffer(), "Test if ->getBuffer() is empty");
$t->ok($subject->generate($modelNames) instanceof doctrineGraphvizMcdGenerator, "Test if generate return a object from type doctrineGraphvizMcdGenerator");
$t->ok(is_string($subject->getBuffer()) && "" !== $subject->getBuffer(), "Test if the current buffer is form type string and not empty");
$t->ok($subject->flushBuffer($modelNames) instanceof doctrineGraphvizMcdGenerator, "Test if ->flushBuffer() return a object from type doctrineGraphvizMcdGenerator");
$t->ok("" === $subject->getBuffer(), "Test if ->flushBuffer() flushed the buffer");
$t->ok($subject->generate($modelNames)->getBuffer() === file_get_contents(dirname(__FILE__) . '/../../../_files/expected/mcd.schema.dot'), "Test the generated graphviz");
try {
    $subject->generate('foo');
    $t->fail('Generate did not throw a exception');
} catch (Exception $e) {
    $t->ok($e instanceof InvalidArgumentException, '->generate throw a InvalidArgumentException');
    $t->ok($e->getMessage() === "First Argument must be from type array. [string] given.", "Test the messsage from exception");
}
开发者ID:yuxw75,项目名称:Surrogate,代码行数:31,代码来源:doctrineGraphvizMcdGeneratorTest.php

示例11: 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::filterInvalidModels($models);
     } else {
         $models = Doctrine::getLoadedModels();
     }
     $connections = array();
     foreach ($models as $model) {
         $connections[Doctrine::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::getTable($model)->createQuery()->delete()->execute();
         }
     }
 }
开发者ID:stelaireri,项目名称:Hive,代码行数:27,代码来源:Data.php

示例12: exportClassesSql

 /**
  * exportClassesSql
  * method for exporting Doctrine_Record classes to a schema
  *
  * @throws Doctrine_Connection_Exception    if some error other than Doctrine::ERR_ALREADY_EXISTS
  *                                          occurred during the create table operation
  * @param array $classes
  * @return void
  */
 public function exportClassesSql(array $classes)
 {
     $models = Doctrine::filterInvalidModels($classes);
     $sql = array();
     foreach ($models as $name) {
         $record = new $name();
         $table = $record->getTable();
         $parents = $table->getOption('joinedParents');
         foreach ($parents as $parent) {
             $data = $table->getConnection()->getTable($parent)->getExportableFormat();
             $query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
             $sql = array_merge($sql, (array) $query);
         }
         $data = $table->getExportableFormat();
         $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::ATTR_EXPORT) & Doctrine::EXPORT_PLUGINS) {
             $sql = array_merge($sql, $this->exportPluginsSql($table));
         }
     }
     $sql = array_unique($sql);
     rsort($sql);
     return $sql;
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:37,代码来源:Export.php


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