當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Doctrine::generateYamlFromDb方法代碼示例

本文整理匯總了PHP中Doctrine::generateYamlFromDb方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine::generateYamlFromDb方法的具體用法?PHP Doctrine::generateYamlFromDb怎麽用?PHP Doctrine::generateYamlFromDb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine的用法示例。


在下文中一共展示了Doctrine::generateYamlFromDb方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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

示例2: execute

 public function execute()
 {
     Doctrine::generateYamlFromDb($this->getArgument('yaml_schema_path'));
     $this->dispatcher->notify('Generate YAML schema successfully from database');
 }
開發者ID:walterfrs,項目名稱:mladek,代碼行數:5,代碼來源:GenerateYamlDb.php

示例3: dirname

<?php

require dirname(__FILE__) . '/../application/global.php';
#$cli = new Doctrine_Cli(Zend_Registry::get('doctrine_config'));
$dconfig = Zend_Registry::get('doctrine_config');
if (isset($_GET['arg'])) {
    if ($_GET['arg'] == 'gen_models') {
        echo "Generating Models <br />\n";
        echo Doctrine::generateModelsFromDb($dconfig["models_path"]);
        //echo Doctrine::generateModelsFromDb();
    } else {
        if ($_GET['arg'] == 'gen_yaml_from_db') {
            echo "Generating Yaml From DB <br />\n";
            echo Doctrine::generateYamlFromDb($dconfig["yaml_schema_path"]);
        }
    }
}
#var_dump ($dconfig);
?>

<br />
<br />
<a href="/ds.php?arg=gen_models">gen_models</a> <br />
<a href="/ds.php?arg=gen_yaml_from_db">gen_yaml_from_db</a> <br />


開發者ID:adnanali,項目名稱:munch,代碼行數:24,代碼來源:doctrine.php

示例4:

<?php

require_once '../Plans.php';
Doctrine::generateYamlFromDb('../db/schema.yaml');
開發者ID:acohn,項目名稱:grinnellplans-php,代碼行數:4,代碼來源:db-to-yaml.php


注:本文中的Doctrine::generateYamlFromDb方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。