/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // get configuration for the given route $config = new sfRoutingConfigHandler(); $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml')); if (!isset($routes[$arguments['route']])) { throw new sfCommandException(sprintf('The route "%s" does not exist.', $arguments['route'])); } $routeOptions = $routes[$arguments['route']]->getOptions(); if (!$routes[$arguments['route']] instanceof sfPropelRouteCollection) { throw new sfCommandException(sprintf('The route "%s" is not a Propel collection route.', $arguments['route'])); } $module = $routeOptions['module']; $model = $routeOptions['model']; // execute the propel:generate-module task $task = new sfPropelGenerateModuleTask($this->dispatcher, $this->formatter); $task->setCommandApplication($this->commandApplication); $taskOptions = array('--theme=' . $options['theme'], '--env=' . $options['env'], '--route-prefix=' . $routeOptions['name'], '--with-propel-route'); if ($routeOptions['with_show']) { $taskOptions[] = '--with-show'; } if ($options['non-verbose-templates']) { $taskOptions[] = '--non-verbose-templates'; } if (!is_null($options['singular'])) { $taskOptions[] = '--singular=' . $options['singular']; } if (!is_null($options['plural'])) { $taskOptions[] = '--plural=' . $options['plural']; } $this->logSection('app', sprintf('Generating module "%s" for model "%s"', $module, $model)); return $task->run(array($arguments['application'], $module, $model), $taskOptions); }
public function setup($options, $parameters = array()) { $this->projectDir = dirname(__FILE__).'/../fixtures'; $this->cleanup(); foreach (array('model', 'urlPrefix', 'moduleName', 'singularName', 'pluralName', 'projectDir') as $param) { if (isset($parameters[$param])) { $this->$param = $parameters[$param]; } } chdir($this->projectDir); $task = new sfPropelGenerateModuleTask(new sfEventDispatcher(), new sfFormatter()); $options[] = 'env=test'; $options[] = 'singular='.$this->singularName; $options[] = 'plural='.$this->pluralName; $options[] = '--non-verbose-templates'; $task->run(array('crud', $this->moduleName, $this->model), $options); require_once($this->projectDir.'/config/ProjectConfiguration.class.php'); sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('crud', 'test', true, $this->projectDir)); return $options; }
public function setup($options) { $this->projectDir = dirname(__FILE__) . '/../fixtures'; $this->cleanup(); chdir($this->projectDir); $task = new sfPropelGenerateModuleTask(new sfEventDispatcher(), new sfFormatter()); $options[] = 'env=test'; $options[] = '--non-verbose-templates'; $task->run(array('crud', 'article', 'Article'), $options); require_once $this->projectDir . '/config/ProjectConfiguration.class.php'; sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('crud', 'test', true, $this->projectDir)); return $options; }
protected function generateForRoute($arguments, $options) { $routeOptions = $arguments['route']->getOptions(); if (!$arguments['route'] instanceof sfPropelRouteCollection) { throw new sfCommandException(sprintf('The route "%s" is not a Propel collection route.', $arguments['route_name'])); } $module = $routeOptions['module']; $model = $routeOptions['model']; // execute the propel:generate-module task $task = new sfPropelGenerateModuleTask($this->dispatcher, $this->formatter); $task->setCommandApplication($this->commandApplication); $taskOptions = array('--theme=' . $options['theme'], '--env=' . $options['env'], '--route-prefix=' . $routeOptions['name'], '--with-propel-route', '--generate-in-cache', '--non-verbose-templates'); if (!is_null($options['singular'])) { $taskOptions[] = '--singular=' . $options['singular']; } if (!is_null($options['plural'])) { $taskOptions[] = '--plural=' . $options['plural']; } $this->logSection('app', sprintf('Generating admin module "%s" for model "%s"', $module, $model)); return $task->run(array($arguments['application'], $module, $model), $taskOptions); }
protected function generateForRoute($arguments, $options) { $routeOptions = $arguments['route']->getOptions(); if (!$arguments['route'] instanceof sfPropel15RouteCollection) { throw new sfCommandException(sprintf('The route "%s" is not a Propel collection route.', $arguments['route_name'])); } $module = $routeOptions['module']; $model = $routeOptions['model']; // execute the propel:generate-module task $task = new sfPropelGenerateModuleTask($this->dispatcher, $this->formatter); $task->setCommandApplication($this->commandApplication); $task->setConfiguration($this->configuration); $this->logSection('app', sprintf('Generating admin module "%s" for model "%s"', $module, $model)); return $task->run(array($arguments['application'], $module, $model), array('theme' => $options['theme'], 'route-prefix' => $routeOptions['name'], 'with-propel-route' => true, 'generate-in-cache' => true, 'non-verbose-templates' => true, 'singular' => $options['singular'], 'plural' => $options['plural'], 'actions-base-class' => $options['actions-base-class'])); }
protected function generate($arguments, $options) { $module = $arguments['module']; $model = $arguments['model']; // execute the propel:generate-module task $task = new sfPropelGenerateModuleTask($this->dispatcher, $this->formatter); $task->setCommandApplication($this->commandApplication); $taskOptions = array('--theme=' . $options['theme'], '--env=' . $options['env'], '--generate-in-cache', '--route-prefix=~', '--non-verbose-templates'); if (!is_null($options['singular'])) { $taskOptions[] = '--singular=' . $options['singular']; } if (!is_null($options['plural'])) { $taskOptions[] = '--plural=' . $options['plural']; } $this->logSection('app', sprintf('Generating admin module "%s" for model "%s"', $module, $model)); return $task->run(array($arguments['application'], $module, $model), $taskOptions); }