/** * @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(); }
protected function execute($arguments = array(), $options = array()) { $this->configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true); $this->context = sfContext::createInstance($this->configuration); $databaseManager = new sfDatabaseManager($this->configuration); $istoptions = array(); if (in_array('no-confirmation', $options)) { $istoptions[] = 'no-confirmation'; } $presetName = $arguments['preset-name']; $fixtureFile = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . $presetName . '.sql'; if (!file_exists($fixtureFile)) { $this->logSection('tempos', sprintf('Preset not found: %s', $presetName), 512, 'ERROR'); return; } else { $this->logSection('tempos', sprintf('Loading preset: %s', $presetName), 512); } $propelInsertSqlTask = new sfPropelInsertSqlTask($this->dispatcher, $this->formatter); $propelInsertSqlTask->run(array(), $istoptions); $sql = file_get_contents($fixtureFile); $con = Propel::getConnection('propel'); $stmt = $con->prepare($sql); $stmt->execute(); }
function installQubit($qubitWebRoot, $qubitDataRoot) { global $fileSystemPathToWebFiles; global $fileSystemPathToDataFiles; // Verify that $fileSystemPathToWebFiles and $fileSystemPathToDataFiles exist. Don't bother // reporting if they are found. if (!file_exists($fileSystemPathToWebFiles)) { reportOnProgress("Verifying location of source files", 'Problem', "Can't find {$fileSystemPathToWebFiles}", "Verify that '{$fileSystemPathToWebFiles}' exists"); $error = true; } if (!file_exists($fileSystemPathToDataFiles)) { reportOnProgress("Verifying location of source files", 'Problem', "Can't find {$fileSystemPathToDataFiles}", "Verify that '{$fileSystemPathToDataFiles}' exists"); $error = true; } // If there are errors, return here since we can't go any further, and we don't want to copy any files. // return $error; // If we made it this far, copy files needed to install Qubit $error = copyFiles($fileSystemPathToWebFiles, $qubitWebRoot, 'web'); $error = copyFiles($fileSystemPathToDataFiles, $qubitDataRoot, 'data'); // Write out index.php controller file $error = writeIndexPhp($qubitWebRoot . 'index.php', $qubitDataRoot . 'lib/QubitConfiguration.class.php'); // Populate db with structure and sample data. We use Symfony's sfPropelInsertSqlTask() and // sfPropelLoadDataTask() objects to do this. To do: Trap errors here and report them with // reportOnProgress(). // First, include Symfony config flass, initialize objects require_once $qubitDataRoot . 'lib/QubitConfiguration.class.php'; $configuration = new QubitConfiguration('dev', true); $dispatcher = new sfEventDispatcher(); $formatter = new sfAnsiColorFormatter(); // We need to chdir into the data directory or symfony complains chdir($qubitDataRoot); // Next, copy template for propel.ini and call a symphony task to populate it and databases.yml $error = copyPropelIni($qubitDataRoot . 'config/propel.ini.tmpl', $qubitDataRoot . 'config/propel.ini'); $error = writeDatabaseConfigFiles($dispatcher, $formatter); // Then, perform SQL tasks. We're no longer checking for $error here, but the user will see errors // if these tasks generate any. $insertSql = new sfPropelInsertSqlTask($dispatcher, $formatter); $insertSql->run(); $loadData = new sfPropelLoadDataTask($dispatcher, $formatter); $loadData->run(array('qubit')); // To do: Perform check to see if mod_rewrite is enabled. We do this by issuing an fopen to a Qubit URL return $error; }
/** * @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; } } } }
public static function insertSql() { $arguments = array(); $options = array(); $options[] = 'no-confirmation'; $dispatcher = sfContext::getInstance()->getEventDispatcher(); $formatter = new sfAnsiColorFormatter(); chdir(sfConfig::get('sf_root_dir')); $insertSql = new sfPropelInsertSqlTask($dispatcher, $formatter); $insertSql->run($arguments, $options); }