本文整理匯總了PHP中Zend_Console_Getopt::addRules方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Console_Getopt::addRules方法的具體用法?PHP Zend_Console_Getopt::addRules怎麽用?PHP Zend_Console_Getopt::addRules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Console_Getopt
的用法示例。
在下文中一共展示了Zend_Console_Getopt::addRules方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: route
public function route(Zend_Controller_Request_Abstract $dispatcher)
{
$getopt = new Zend_Console_Getopt(array());
$getopt->addRules(array('controller|c=s' => 'Controller Name', 'action|a=s' => 'Controller Action', 'from|f=s' => 'From yyyy-mm-dd', 'to|t=s' => 'To yyyy-mm-dd'));
$arguments = $getopt->getRemainingArgs();
if ($getopt->getOption('controller') && $getopt->getOption('action')) {
$dispatcher->setControllerName($getopt->getOption('controller'));
$dispatcher->setActionName($getopt->getOption('action'));
$dispatcher->setParams(array('from' => $getopt->getOption('from'), 'to' => $getopt->getOption('to')));
return $dispatcher;
}
}
示例2: testAddRulesDoesNotThrowWarnings
/**
* @group ZF-2064
*/
public function testAddRulesDoesNotThrowWarnings()
{
// Fails if warning is thrown: Should not happen!
$opts = new Zend_Console_Getopt('abp:');
$opts->addRules(array('verbose|v' => 'Print verbose output'));
}
示例3: testAddRules
public function testAddRules()
{
$opts = new Zend_Console_Getopt(array('apple|a' => 'Apple option', 'banana|b' => 'Banana option'), array('--pear', 'pear_param'));
try {
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
$this->assertEquals($e->getMessage(), 'Option "pear" is not recognized.');
}
$opts->addRules(array('pear|p=s' => 'Pear option'));
$this->assertEquals($opts->pear, 'pear_param');
}
示例4: _parseParams
private function _parseParams($context, $argv)
{
$opts = new Zend_Console_Getopt();
$aliases = array();
foreach ($context->attribute as $attribute) {
// Key should be the rule string, value is the long usage
$opts->addRules(array($attribute->getopt, $attribute->usage));
}
$opts->addArguments($argv);
return $opts->parse();
}