/** * 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); }
try { $manager->getOptionValue('nonexistant'); $t->fail('->getOptionValue() throws a sfCommandException if the option name does not exist'); } catch (sfCommandException $e) { $t->pass('->getOptionValue() throws a sfCommandException if the option name does not exist'); } // ->getArgumentValue() $t->diag('->getArgumentValue()'); foreach ($arguments as $name => $value) { $t->is($manager->getArgumentValue($name), $value, '->getArgumentValue() returns the value for the given argument name'); } try { $manager->getArgumentValue('nonexistant'); $t->fail('->getArgumentValue() throws a sfCommandException if the argument name does not exist'); } catch (sfCommandException $e) { $t->pass('->getArgumentValue() throws a sfCommandException if the argument name does not exist'); } // ->isValid() ->getErrors() $t->diag('->isValid() ->getErrors()'); $argumentSet = new sfCommandArgumentSet();