public function execute()
 {
     try {
         $migrationsPath = $this->getArgument('migrations_path');
         $modelsPath = $this->getArgument('models_path');
         $yamlSchemaPath = $this->getArgument('yaml_schema_path');
         $migration = new Doctrine_Migration($migrationsPath);
         $result1 = false;
         if (!count($migration->getMigrationClasses())) {
             $builder = new Doctrine_Migration_Builder($migration);
             $result1 = $builder->generateMigrationsFromModels($modelsPath);
         }
         $diff = new Doctrine_Migration_Diff($modelsPath, $yamlSchemaPath, $migration);
         $changes = $diff->generateMigrationClasses();
         $numChanges = count($changes, true) - count($changes);
         $result = $result1 || $numChanges ? true : false;
     } catch (Exception $e) {
         $result = false;
     }
     if (!$result) {
         throw new Doctrine_Task_Exception('Could not generate migration classes from models' . (isset($e) ? ': ' . $e->getMessage() : null));
     } else {
         $this->notify('Generated migration classes successfully from models');
     }
 }
 public function testMigrationClassNameInflected()
 {
     $tests = array('test-class-Name', 'test_class_name', 'TestClassName', 'test:class:name', 'test(class)name', 'test*class*name', 'test class name', 'test&class&name');
     $builder = new Doctrine_Migration_Builder();
     foreach ($tests as $test) {
         $code = $builder->generateMigrationClass($test);
         $this->assertTrue(strpos($code, 'TestClassName'));
     }
 }
Exemplo n.º 3
0
 /**
  * Generate a set of migration classes from an existing set of models
  *
  * @param string  $migrationsPath Path to your Doctrine migration classes
  * @param string  $modelsPath     Path to your Doctrine model classes
  * @param integer $modelLoading   Style of model loading to use for loading the models in order to generate migrations
  * @return void
  */
 public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null, $modelLoading = null)
 {
     $builder = new Doctrine_Migration_Builder($migrationsPath);
     return $builder->generateMigrationsFromModels($modelsPath, $modelLoading);
 }
Exemplo n.º 4
0
 /**
  * Generate a migration class for the changes in this diff instance
  *
  * @return array $changes
  */
 public function generateMigrationClasses()
 {
     $builder = new Doctrine_Migration_Builder($this->_migration);
     return $builder->generateMigrationsFromDiff($this);
 }
Exemplo n.º 5
0
    /**
     * loadTemplate
     * 
     * Loads the class template used for generating classes
     *
     * @return void
     */
    protected function loadTemplate()
    {
        if (isset(self::$tpl)) {
            return;
        }
        self::$tpl = <<<END
/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class %s extends %s
{
\tpublic function up()
\t{
%s
\t}

\tpublic function down()
\t{
%s
\t}
}
END;
    }