/** * Dynamically adds options to this task based on the current route. * * @param sfCommandManager $commandManager * @param array $options Options as read from commandline * * @return void * @see sfTask */ protected function process(sfCommandManager $commandManager, $options) { $commandManager->process($options); if (array_key_exists('application', $commandManager->getArgumentValues()) && array_key_exists('sf_route', $commandManager->getArgumentValues())) { $application = $commandManager->getArgumentValue('application'); $routeName = $commandManager->getArgumentValue('sf_route'); $configuration = $this->createConfiguration($application, 'prod'); $this->route = sfImageTransformExtraPluginConfiguration::getRoute($routeName, $configuration); $routeVariables = array_keys($this->route->getVariables()); $this->options = array(); $optionSet = new sfCommandOptionSet(); foreach ($commandManager->getErrors() as $error) { if (preg_match('/"--([\\w-_]+)"/', $error, $matches) && in_array($matches[1], $routeVariables)) { $option = new sfCommandOption($matches[1], null, sfCommandOption::PARAMETER_OPTIONAL, '', null); $this->options[] = $option; $optionSet->addOption($option); } } $commandManager->setOptionSet($optionSet); } parent::process($commandManager, $options); }
'foo4' => 'foo4', 'foo5' => 'foo5', 'foo6' => 'foo6 foo6', 'foo7' => 'foo7', 'foo8' => array('foo', 'bar'), 'foo9' => 'default9', 'foo10' => 'foo10', 'foo11' => 'foo11', ); $arguments = array( 'foo1' => 'foo1', 'foo2' => array('foo2', 'foo3', 'foo4') ); $t->ok($manager->isValid(), '->process() processes CLI options'); $t->is($manager->getOptionValues(), $options, '->process() processes CLI options'); $t->is($manager->getArgumentValues(), $arguments, '->process() processes CLI options'); // ->getOptionValue() $t->diag('->getOptionValue()'); foreach ($options as $name => $value) { $t->is($manager->getOptionValue($name), $value, '->getOptionValue() returns the value for the given option name'); } try { $manager->getOptionValue('nonexistant'); $t->fail('->getOptionValue() throws a sfCommandException if the option name does not exist'); } catch (sfCommandException $e) {