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


PHP sfSimpleAutoload::register方法代码示例

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


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

示例1: execute

 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $tmpdir = sfConfig::get('sf_cache_dir') . '/models_tmp';
     $ymlTmp = $tmpdir . '/yaml';
     $modelTmp = $tmpdir . '/model';
     $this->getFileSystem()->mkdirs($ymlTmp);
     $this->getFileSystem()->mkdirs($modelTmp);
     $migrationsPath = sfConfig::get('sf_data_dir') . '/migrations/generated';
     $config = $this->getCliConfig();
     $manager = Doctrine_Manager::getInstance();
     $oldAttr = $manager->getAttribute(Doctrine::ATTR_MODEL_LOADING);
     $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_AGGRESSIVE);
     sfSimpleAutoload::unregister();
     Doctrine::generateYamlFromDb($ymlTmp . '/from.yml', array(), array('generateBaseClasses' => false));
     sfSimpleAutoload::register();
     $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, $oldAttr);
     $models = sfFinder::type('file')->name('*.php')->in($config['models_path']);
     foreach ($models as $model) {
         $dirname = basename(dirname($model));
         $filename = basename($model);
         if ('base' !== $dirname) {
             continue;
         }
         $normalModelName = str_replace('Base', '', basename($model, '.class.php'));
         $normalModelRefClass = new ReflectionClass($normalModelName);
         if ($normalModelRefClass && $normalModelRefClass->isAbstract()) {
             continue;
         }
         $content = file_get_contents($model);
         $content = str_replace('abstract class Base', 'class ToPrfx', $content);
         $content = str_replace('extends opDoctrineRecord', 'extends Doctrine_Record', $content);
         $matches = array();
         if (preg_match('/\\$this->setTableName\\(\'([^\']+)\'\\);/', $content, $matches)) {
             $tableName = $matches[1];
             $content = preg_replace('/class [a-zA-Z0-9_]+/', 'class ToPrfx' . Doctrine_Inflector::classify($tableName), $content);
             file_put_contents($modelTmp . '/ToPrfx' . Doctrine_Inflector::classify($tableName) . '.class.php', $content);
         } else {
             file_put_contents($modelTmp . '/' . str_replace('Base', 'ToPrfx', $filename), $content);
         }
     }
     $migration = new Doctrine_Migration($migrationsPath);
     $diff = new opMigrationDiff($ymlTmp . '/from.yml', $modelTmp, $migration);
     $changes = $diff->generateMigrationClasses();
     $this->getFileSystem()->remove($ymlTmp);
     $this->getFileSystem()->remove($modelTmp);
     $numChanges = count($changes, true) - count($changes);
     if (!$numChanges) {
         throw new Doctrine_Task_Exception('Could not generate migration classes from difference');
     } else {
         $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('doctrine', 'Generated migration classes successfully from difference'))));
     }
 }
开发者ID:Kazuhiro-Murota,项目名称:OpenPNE3,代码行数:53,代码来源:openpneGenerateMigrationsTask.class.php


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