public function initializePropel()
 {
     // build Propel om/map/sql/forms
     $files = glob(sfConfig::get('sf_lib_dir') . '/model/om/*.php');
     if (false === $files || !count($files)) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfPropelBuildModelTask($this->dispatcher, new sfFormatter());
         ob_start();
         $task->run();
         $output = ob_get_clean();
     }
     $files = glob(sfConfig::get('sf_data_dir') . '/sql/*.php');
     if (false === $files || !count($files)) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfPropelBuildSqlTask($this->dispatcher, new sfFormatter());
         ob_start();
         $task->run();
         $output = ob_get_clean();
     }
     $files = glob(sfConfig::get('sf_lib_dir') . '/form/base/*.php');
     if (false === $files || !count($files)) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfPropelBuildFormsTask($this->dispatcher, new sfFormatter());
         $task->run();
     }
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $buildSql = new sfPropelBuildSqlTask($this->dispatcher, $this->formatter);
     $buildSql->setCommandApplication($this->commandApplication);
     $buildSql->run();
     $this->logSection("sql-diff", "building database patch");
     $i = new dbInfo();
     $i->loadFromDb(Propel::getConnection($options['connection']));
     $i2 = new dbInfo();
     $sqlDir = sfConfig::get('sf_data_dir') . '/sql';
     $dbmap = file("{$sqlDir}/sqldb.map");
     foreach ($dbmap as $mapline) {
         if ($mapline[0] == '#') {
             continue;
         }
         //it is a comment
         list($sqlfile, $dbname) = explode('=', trim($mapline));
         if ($dbname == $options['connection']) {
             $i2->loadFromFile("{$sqlDir}/{$sqlfile}");
         }
     }
     $diff = $i->getDiffWith($i2);
     $filename = sfConfig::get('sf_data_dir') . "/sql/{$options['connection']}.diff.sql";
     if ($diff == '') {
         $this->logSection("sql-diff", "no difference found");
     }
     $this->logSection('sql-diff', "writing file {$filename}");
     file_put_contents($filename, $diff);
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $buildModel = new sfPropelBuildModelTask($this->dispatcher, $this->formatter);
     $buildModel->setCommandApplication($this->commandApplication);
     $buildModel->run();
     $buildSql = new sfPropelBuildSqlTask($this->dispatcher, $this->formatter);
     $buildSql->setCommandApplication($this->commandApplication);
     $buildSql->run();
     if (!$options['skip-forms']) {
         $buildForms = new sfPropelBuildFormsTask($this->dispatcher, $this->formatter);
         $buildForms->setCommandApplication($this->commandApplication);
         $buildForms->run();
     }
     $insertSql = new sfPropelInsertSqlTask($this->dispatcher, $this->formatter);
     $insertSql->setCommandApplication($this->commandApplication);
     $insertSql->run();
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $buildSql = new sfPropelBuildSqlTask($this->dispatcher, $this->formatter);
     $buildSql->setCommandApplication($this->commandApplication);
     $buildSql->run();
     $this->logSection("propel-diff", "building database patch");
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $i = new dbInfo();
     $i->loadFromDb();
     $i2 = new dbInfo();
     $i2->loadAllFilesInDir(sfConfig::get('sf_data_dir') . '/sql');
     $diff = $i->getDiffWith($i2);
     $filename = sfConfig::get('sf_data_dir') . '/sql/diff.sql';
     if ($diff == '') {
         $this->logSection("propel-diff", "no difference found");
     }
     $this->logSection('propel-sql-diff', "writing file {$filename}");
     file_put_contents($filename, $diff);
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $basePhingOptions = array();
     foreach ($options['phing-arg'] as $arg) {
         $basePhingOptions[] = '--phing-arg=' . escapeshellarg($arg);
     }
     $buildModel = new sfPropelBuildModelTask($this->dispatcher, $this->formatter);
     $buildModel->setCommandApplication($this->commandApplication);
     $ret = $buildModel->run(array(), $basePhingOptions);
     if ($ret) {
         return $ret;
     }
     if (!$options['skip-forms']) {
         $this->logBlock(array('Phing was run before and used many custom classes that might conflict with', 'your model classes. In case of errors try running "propel:build-forms" and', '"propel:build-filters" alone. This is due to a PHP limitation that cannot be', 'fixed in symfony.'), 'INFO');
         $buildForms = new sfPropelBuildFormsTask($this->dispatcher, $this->formatter);
         $buildForms->setCommandApplication($this->commandApplication);
         $ret = $buildForms->run();
         if ($ret) {
             return $ret;
         }
         $buildFilters = new sfPropelBuildFiltersTask($this->dispatcher, $this->formatter);
         $buildFilters->setCommandApplication($this->commandApplication);
         $ret = $buildFilters->run();
         if ($ret) {
             return $ret;
         }
     }
     if (!$options['classes-only']) {
         $buildSql = new sfPropelBuildSqlTask($this->dispatcher, $this->formatter);
         $buildSql->setCommandApplication($this->commandApplication);
         $ret = $buildSql->run(array(), $basePhingOptions);
         if ($ret) {
             return $ret;
         }
         $insertSql = new sfPropelInsertSqlTask($this->dispatcher, $this->formatter);
         $insertSql->setCommandApplication($this->commandApplication);
         $insertSqlOptions = array_merge($basePhingOptions, array('--env=' . $options['env'], '--connection=' . $options['connection']));
         if ($options['application']) {
             $insertSqlOptions[] = '--application=' . $options['application'];
         }
         if ($options['no-confirmation']) {
             $insertSqlOptions[] = '--no-confirmation';
         }
         $ret = $insertSql->run(array(), $insertSqlOptions);
         if ($ret) {
             return $ret;
         }
     }
 }
 /**
  * @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 propel:build", join(', --', array_keys($this->getBuildOptions()))));
     }
     if (self::BUILD_MODEL == (self::BUILD_MODEL & $mode)) {
         $task = new sfPropelBuildModelTask($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 sfPropelBuildFormsTask($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 sfPropelBuildFiltersTask($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 sfPropelBuildSqlTask($this->dispatcher, $this->formatter);
         $task->setCommandApplication($this->commandApplication);
         $task->setConfiguration($this->configuration);
         $ret = $task->run();
         if ($ret) {
             return $ret;
         }
     }
     if (self::BUILD_DB == (self::BUILD_DB & $mode)) {
         $task = new sfPropelInsertSqlTask($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;
         }
     }
     if (count($options['and-load']) || count($options['and-append'])) {
         $task = new sfPropelDataLoadTask($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;
             }
         }
     }
 }