本文整理汇总了PHP中CommandContext::setSubject方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandContext::setSubject方法的具体用法?PHP CommandContext::setSubject怎么用?PHP CommandContext::setSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandContext
的用法示例。
在下文中一共展示了CommandContext::setSubject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute an action by triggering a method in the derived class.
*
* @param string $action The action to execute
* @param CommandContext $context A command context object
* @throws ControllerException If the action method doesn't exist
* @return mixed|false The value returned by the called method, false in error case.
*/
public function execute($action, CommandContext $context)
{
$action = strtolower($action);
//Update the context
$context->action = $action;
$context->setSubject($this);
//Find the mapped action
if (isset($this->_action_map[$action])) {
$command = $this->_action_map[$action];
} else {
$command = $action;
}
//Execute the action
if ($this->getCommandChain()->run('before.' . $command, $context) !== false) {
$method = '_action' . ucfirst($command);
if (!method_exists($this, $method)) {
if (isset($this->_mixed_methods[$command])) {
$context->result = $this->_mixed_methods[$command]->execute('action.' . $command, $context);
} else {
throw new ControllerExceptionNotImplemented("Can't execute '{$command}', method: '{$method}' does not exist");
}
} else {
$context->result = $this->{$method}($context);
}
$this->getCommandChain()->run('after.' . $command, $context);
}
return $context->result;
}