protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     if (!$options['skip-build']) {
         $buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter);
         $buildModel->setCommandApplication($this->commandApplication);
         $buildModel->setConfiguration($this->configuration);
         $buildModel->run();
     }
     $connections = array();
     $models = $arguments['models'];
     foreach ($models as $key => $model) {
         $model = trim($model);
         $conn = Doctrine_Core::getTable($model)->getConnection();
         $connections[$conn->getName()][] = $model;
     }
     foreach ($connections as $name => $models) {
         $this->logSection('doctrine', 'dropping model tables for connection "' . $name . '"');
         $conn = Doctrine_Manager::getInstance()->getConnection($name);
         $models = $conn->unitOfWork->buildFlushTree($models);
         $models = array_reverse($models);
         foreach ($models as $model) {
             $tableName = Doctrine_Core::getTable($model)->getOption('tableName');
             $this->logSection('doctrine', 'dropping table "' . $tableName . '"');
             try {
                 $conn->export->dropTable($tableName);
             } catch (Exception $e) {
                 $this->logSection('doctrine', 'dropping table failed: ' . $e->getMessage());
             }
         }
         $this->logSection('doctrine', 'recreating tables for models');
         Doctrine_Core::createTablesFromArray($models);
     }
 }
 public function run()
 {
     opApplicationConfiguration::unregisterZend();
     $task = new sfDoctrineBuildModelTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => 'pc_frontend', 'env' => sfConfig::get('sf_environment', 'prod')));
     $task = new sfCacheClearTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => null, 'env' => sfConfig::get('sf_environment', 'prod')));
     opApplicationConfiguration::registerZend();
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter);
     $buildModel->setCommandApplication($this->commandApplication);
     $buildModel->run();
     $this->logSection('doctrine', 'generating form classes');
     $databaseManager = new sfDatabaseManager($this->configuration);
     $generatorManager = new sfGeneratorManager($this->configuration);
     $generatorManager->generate('sfDoctrineFormGenerator', array('connection' => $options['connection'], 'model_dir_name' => $options['model-dir-name'], 'form_dir_name' => $options['form-dir-name']));
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $buildDb = new sfDoctrineBuildDbTask($this->dispatcher, $this->formatter);
     $buildDb->setCommandApplication($this->commandApplication);
     $buildDb->run(array('application' => $arguments['application']), array('--env=' . $options['env']));
     $buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter);
     $buildModel->setCommandApplication($this->commandApplication);
     $buildModel->run(array('application' => $arguments['application']), array('--env=' . $options['env']));
     $insertSql = new sfDoctrineInsertSqlTask($this->dispatcher, $this->formatter);
     $insertSql->setCommandApplication($this->commandApplication);
     $insertSql->run(array('application' => $arguments['application']), array('--env=' . $options['env']));
 }
Пример #5
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $buildDb = new sfDoctrineBuildDbTask($this->dispatcher, $this->formatter);
     $buildDb->setCommandApplication($this->commandApplication);
     $buildDbOptions = array();
     if (isset($options['application']) && $options['application']) {
         $buildDbOptions[] = '--application=' . $options['application'];
     }
     $buildDbOptions[] = '--env=' . $options['env'];
     $buildDb->run(array(), $buildDbOptions);
     $buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter);
     $buildModel->setCommandApplication($this->commandApplication);
     $buildModelOptions = array();
     if (isset($options['application']) && $options['application']) {
         $buildModelOptions[] = '--application=' . $options['application'];
     }
     $buildModelOptions[] = '--env=' . $options['env'];
     $ret = $buildModel->run(array(), $buildModelOptions);
     if ($ret) {
         return $ret;
     }
     $buildSql = new sfDoctrineBuildSqlTask($this->dispatcher, $this->formatter);
     $buildSql->setCommandApplication($this->commandApplication);
     $ret = $buildSql->run();
     if ($ret) {
         return $ret;
     }
     if (!$options['skip-forms']) {
         $buildForms = new sfDoctrineBuildFormsTask($this->dispatcher, $this->formatter);
         $buildForms->setCommandApplication($this->commandApplication);
         $ret = $buildForms->run();
         if ($ret) {
             return $ret;
         }
         $buildFilters = new sfDoctrineBuildFiltersTask($this->dispatcher, $this->formatter);
         $buildFilters->setCommandApplication($this->commandApplication);
         $ret = $buildFilters->run();
         if ($ret) {
             return $ret;
         }
     }
     $insertSql = new sfDoctrineInsertSqlTask($this->dispatcher, $this->formatter);
     $insertSql->setCommandApplication($this->commandApplication);
     $insertSqlOptions = array();
     $insertSqlOptions[] = '--env=' . $options['env'];
     $insertSqlOptions = array();
     if (isset($options['application']) && $options['application']) {
         $insertSqlOptions[] = '--application=' . $options['application'];
     }
     $ret = $insertSql->run(array(), $insertSqlOptions);
     return $ret;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $baseOptions = $this->configuration instanceof sfApplicationConfiguration ? array('--application=' . $this->configuration->getApplication(), '--env=' . $options['env']) : array();
     $buildDb = new sfDoctrineBuildDbTask($this->dispatcher, $this->formatter);
     $buildDb->setCommandApplication($this->commandApplication);
     $ret = $buildDb->run(array(), $baseOptions);
     if ($ret) {
         return $ret;
     }
     $buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter);
     $buildModel->setCommandApplication($this->commandApplication);
     $ret = $buildModel->run(array(), $baseOptions);
     if ($ret) {
         return $ret;
     }
     $buildSql = new sfDoctrineBuildSqlTask($this->dispatcher, $this->formatter);
     $buildSql->setCommandApplication($this->commandApplication);
     $ret = $buildSql->run(array(), $baseOptions);
     if ($ret) {
         return $ret;
     }
     if (!$options['skip-forms']) {
         $buildForms = new sfDoctrineBuildFormsTask($this->dispatcher, $this->formatter);
         $buildForms->setCommandApplication($this->commandApplication);
         $ret = $buildForms->run(array(), $baseOptions);
         if ($ret) {
             return $ret;
         }
         $buildFilters = new sfDoctrineBuildFiltersTask($this->dispatcher, $this->formatter);
         $buildFilters->setCommandApplication($this->commandApplication);
         $ret = $buildFilters->run(array(), $baseOptions);
         if ($ret) {
             return $ret;
         }
     }
     $insertSql = new sfDoctrineInsertSqlTask($this->dispatcher, $this->formatter);
     $insertSql->setCommandApplication($this->commandApplication);
     $ret = $insertSql->run(array(), $baseOptions);
     return $ret;
 }
Пример #7
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     if (!($mode = $this->calculateMode($options))) {
         throw new InvalidArgumentException(sprintf("You must include one or more of the following build options:\n--%s\n\nSee this task's help page for more information:\n\n  php symfony help doctrine:build", join(', --', array_keys($this->getBuildOptions()))));
     }
     if (self::BUILD_DB == (self::BUILD_DB & $mode)) {
         $task = new sfDoctrineDropDbTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run(array(), array('no-confirmation' => $options['no-confirmation']));
         if ($ret) {
             return $ret;
         }
         $task = new sfDoctrineBuildDbTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run();
         if ($ret) {
             return $ret;
         }
         // :insert-sql (or :migrate) will also be run, below
     }
     if (self::BUILD_MODEL == (self::BUILD_MODEL & $mode)) {
         $task = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run();
         if ($ret) {
             return $ret;
         }
     }
     if (self::BUILD_FORMS == (self::BUILD_FORMS & $mode)) {
         $task = new sfDoctrineBuildFormsTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run();
         if ($ret) {
             return $ret;
         }
     }
     if (self::BUILD_FILTERS == (self::BUILD_FILTERS & $mode)) {
         $task = new sfDoctrineBuildFiltersTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run();
         if ($ret) {
             return $ret;
         }
     }
     if (self::BUILD_SQL == (self::BUILD_SQL & $mode)) {
         $task = new sfDoctrineBuildSqlTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run();
         if ($ret) {
             return $ret;
         }
     }
     if ($options['and-migrate']) {
         $task = new sfDoctrineMigrateTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run();
         if ($ret) {
             return $ret;
         }
     } else {
         if (self::BUILD_DB == (self::BUILD_DB & $mode)) {
             $task = new sfDoctrineInsertSqlTask($this->dispatcher, $this->formatter);
             $task->setCommandApplication($this->commandApplication);
             $task->setConfiguration($this->configuration);
             $ret = $task->run();
             if ($ret) {
                 return $ret;
             }
         }
     }
     if (count($options['and-load']) || count($options['and-append'])) {
         $task = new sfDoctrineDataLoadTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         if (count($options['and-load'])) {
             $ret = $task->run(array('dir_or_file' => in_array(array(), $options['and-load'], true) ? null : $options['and-load']));
             if ($ret) {
                 return $ret;
             }
         }
         if (count($options['and-append'])) {
             $ret = $task->run(array('dir_or_file' => in_array(array(), $options['and-append'], true) ? null : $options['and-append']), array('append' => true));
             if ($ret) {
                 return $ret;
             }
         }
     }
 }
 protected function buildModel()
 {
     $task = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter);
     $task->run();
     $task = new sfDoctrineBuildFormsTask($this->dispatcher, $this->formatter);
     $task->run();
     $task = new sfDoctrineBuildFiltersTask($this->dispatcher, $this->formatter);
     $task->run();
     $task = new sfCacheClearTask($this->dispatcher, $this->formatter);
     $task->run();
     $task = new openpnePermissionTask($this->dispatcher, $this->formatter);
     $task->run();
 }