本文整理汇总了PHP中Zend_Controller_Request_Abstract::setUserLogin方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract::setUserLogin方法的具体用法?PHP Zend_Controller_Request_Abstract::setUserLogin怎么用?PHP Zend_Controller_Request_Abstract::setUserLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Abstract
的用法示例。
在下文中一共展示了Zend_Controller_Request_Abstract::setUserLogin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
/**
* Processes a request and sets its controller and action. If
* no route was possible, an exception is thrown.
*
* @param \Zend_Controller_Request_Abstract
* @throws \Zend_Controller_Router_Exception
* @return \Zend_Controller_Request_Abstract|boolean
*/
public function route(\Zend_Controller_Request_Abstract $request)
{
$options = array('help|h' => 'Show this help', 'org|o=i' => 'The user organization number', 'pwd|p=s' => 'User password', 'user|u=s' => 'The user name');
$getopt = new \Zend_Console_Getopt($options);
try {
$getopt->parse();
} catch (\Zend_Console_Getopt_Exception $e) {
echo $this->_expandMessage($e);
exit;
}
if ($getopt->getOption('h')) {
// $getopt->s
echo $this->_expandMessage($getopt);
exit;
}
if ($request instanceof \MUtil_Controller_Request_Cli) {
$request->setUserLogin($getopt->getOption('u'), $getopt->getOption('o'), $getopt->getOption('p'));
}
$arguments = $getopt->getRemainingArgs();
if ($arguments) {
$controller = array_shift($arguments);
$action = array_shift($arguments);
if (!$action) {
$action = 'index';
}
if (preg_match('/^\\w+(-\\w+)*$/', $controller) && preg_match('/^\\w+(-\\w+)*$/', $action)) {
$request->setControllerName($controller);
$request->setActionName($action);
$params[$request->getControllerKey()] = $controller;
$params[$request->getActionKey()] = $action;
foreach ($arguments as $arg) {
if (\MUtil_String::contains($arg, '=')) {
list($name, $value) = explode('=', $arg, 2);
} else {
$name = $arg;
$value = '';
}
$params[$name] = $value;
}
$request->setParams($params);
return $request;
}
echo "Invalid command: {$controller}/{$action}.\n", exit;
}
echo "No command given.\n\n";
echo $this->_expandMessage($getopt), exit;
}