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


PHP Doctrine::getLoadedModelFiles方法代码示例

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


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

示例1: testModelLoadingCacheInformation

 public function testModelLoadingCacheInformation()
 {
     $models = Doctrine::getLoadedModels();
     $this->assertTrue(in_array('AggressiveModelLoadingUser', $models));
     $this->assertTrue(in_array('ConservativeModelLoadingProfile', $models));
     $this->assertTrue(in_array('ConservativeModelLoadingContact', $models));
     $modelFiles = Doctrine::getLoadedModelFiles();
     $this->assertTrue(file_exists($modelFiles['ConservativeModelLoadingUser']));
     $this->assertTrue(file_exists($modelFiles['ConservativeModelLoadingProfile']));
     $this->assertTrue(file_exists($modelFiles['ConservativeModelLoadingContact']));
 }
开发者ID:swk,项目名称:bluebox,代码行数:11,代码来源:BaseTestCase.php

示例2: find_table_with_column

function find_table_with_column($colname)
{
    // check the last table looked at
    global $last_tbl_cache;
    if ($last_tbl_cache && $last_tbl_cache->hasColumn($colname)) {
        return $last_tbl_cache;
    }
    // search all the models
    $models = Doctrine::getLoadedModelFiles();
    foreach ($models as $name => $loc) {
        if ($name != 'TankSource') {
            $t = Doctrine::getTable($name);
            if ($t->hasColumn($colname)) {
                $last_tbl_cache = $t;
                return $t;
            }
        }
    }
    throw new Exception("Unable to find table with column '{$colname}'");
}
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:20,代码来源:tank-def.php

示例3: setUp

 public function setUp()
 {
     $thisClass = $this->getInvoker();
     $thisClassName = $thisClass->getTable()->getComponentName();
     if (!empty($thisClass->relationType)) {
         $this->relationType = $thisClass->relationType;
         $mode = ' hasMany ';
     } else {
         $mode = ' hasOne ';
     }
     // If this class is extending Bluebox_Class directly, then load any possibly related models and setup our subclasses
     if (get_parent_class($thisClass) == 'Bluebox_Record') {
         // Go through every model and figure out if it is an extension of this model. If so, relate it via subclasses
         // Note that for efficiency, we assume that we only need to inspect classes that end in the same name as our base class
         // i.e. if the base class is named 'Device' we would only look at other models named things like 'SipDevice' or 'IaxDevice'
         //kohana::log('debug', '*** We are setting up the base class ' . $thisClassName . '...');
         foreach (Doctrine::getLoadedModelFiles() as $model => $dir) {
             if (substr($model, strlen($model) - strlen($thisClassName), strlen($thisClassName)) == $thisClassName) {
                 if (is_subclass_of($model, $thisClassName)) {
                     Doctrine::initializeModels($model);
                 }
             }
         }
     } else {
         // We are extending some other class. Figure out the pieces
         $baseClassName = get_parent_class($thisClass);
         $relatesTo = substr($thisClassName, 0, strlen($thisClassName) - strlen($baseClassName));
         if (self::DEBUG) {
             kohana::log('debug', '*** Setting up extended version of ' . $baseClassName . ' (' . $thisClassName . ")");
         }
         if (class_exists($relatesTo, TRUE)) {
             $relatedPrimaryKey = Doctrine::getTable($relatesTo)->getIdentifier();
             if (self::DEBUG) {
                 kohana::log('debug', $thisClassName . $mode . $relatesTo);
             }
             // Relate this class to the foreign model. So if this was DeviceNumber, this would relate us to Device
             if ($this->relationType == Doctrine_Relation::MANY) {
                 $thisClass->hasMany($relatesTo, array('local' => 'foreign_id', 'foreign' => $relatedPrimaryKey), $this->relationType);
             } else {
                 $thisClass->hasOne($relatesTo, array('local' => 'foreign_id', 'foreign' => $relatedPrimaryKey), $this->relationType);
             }
             // Also relate the base class to the foreign model.
             if (self::DEBUG) {
                 kohana::log('debug', $baseClassName . $mode . $relatesTo);
             }
             $foreignTable = Doctrine::getTable($baseClassName);
             $foreignTable->bind(array($relatesTo, array('local' => 'foreign_id', 'foreign' => $relatedPrimaryKey)), $this->relationType);
             // Unfortunately, we can't turn off individual constraints in Doctrine. So we must turn off constratints for the
             // entire table, because foreign_id may map to multiple different other tables. This is only necessary on
             // concrete tables, since the inheritance tables aren't "real" tables and don't get created anyway.
             // TODO: Find a better solution to keeping constraint checks !
             $thisClass->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL ^ Doctrine::EXPORT_CONSTRAINTS);
             $foreignTable->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL ^ Doctrine::EXPORT_CONSTRAINTS);
             // Create the relation on the other side, too
             if (self::DEBUG) {
                 kohana::log('debug', $relatesTo . $mode . $thisClassName . " (as {$baseClassName})");
             }
             $foreignTable = Doctrine::getTable($relatesTo);
             $foreignTable->bind(array($thisClassName . ' as ' . $baseClassName, array('local' => $relatedPrimaryKey, 'foreign' => 'foreign_id')), $this->relationType);
             // Now also relate to subclasses of the foreign model. So if there were other types of Devices, relate us to them, too
             foreach (Doctrine::getLoadedModelFiles() as $model => $dir) {
                 if (substr($model, strlen($model) - strlen($relatesTo), strlen($relatesTo)) == $relatesTo) {
                     if (is_subclass_of($model, $relatesTo)) {
                         if (self::DEBUG) {
                             kohana::log('debug', $model . $mode . $thisClassName . " (searched for instances of {$relatesTo})\n");
                         }
                         Doctrine::getTable($thisClassName)->addRecordListener(new PolymorphicRecordListener($model));
                         $foreignTable = Doctrine::getTable($model);
                         $foreignTable->bind(array($thisClassName . ' as ' . $baseClassName, array('local' => $relatedPrimaryKey, 'foreign' => 'foreign_id')), $this->relationType);
                     }
                 }
             }
         }
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:75,代码来源:Polymorphic.php

示例4: _cleanup

 /**
  * Cleanup temporary generated models after a diff is performed
  *
  * @return void
  */
 protected function _cleanup()
 {
     $modelFiles = Doctrine::getLoadedModelFiles();
     $filesToClean = array_diff($modelFiles, $this->_startingModelFiles);
     foreach ($filesToClean as $file) {
         if (file_exists($file)) {
             unlink($file);
         }
     }
     // clean up tmp directories
     Doctrine_Lib::removeDirectories(sys_get_temp_dir() . DIRECTORY_SEPARATOR . strtolower(self::$_fromPrefix) . '_doctrine_tmp_dirs');
     Doctrine_Lib::removeDirectories(sys_get_temp_dir() . DIRECTORY_SEPARATOR . strtolower(self::$_toPrefix) . '_doctrine_tmp_dirs');
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:18,代码来源:Diff.php


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