本文整理汇总了PHP中Phalcon\Mvc\Dispatcher::getHandlerClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::getHandlerClass方法的具体用法?PHP Dispatcher::getHandlerClass怎么用?PHP Dispatcher::getHandlerClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::getHandlerClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeExecuteRoute
/**
* Execute before the router so we can determine if this is a private controller, and must be authenticated, or a
* public controller that is open to all.
*
* @param Dispatcher $dispatcher
* @return boolean
*/
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
$controllerName = $dispatcher->getControllerName();
// this is not namespaced
$controllerName = $dispatcher->getHandlerClass();
// this IS namespaced
// Only check permissions on private controllers
// By virtue of extending BaseAuth, this is a private controller
// Get the current identity
$identity = $this->auth->getIdentity();
// If there is no identity available the user is redirected to index/index
if (!is_array($identity)) {
$this->flashSession->warning('Please sign in.');
$dispatcher->forward(array('controller' => 'session', 'action' => 'login'));
return false;
}
//$this->flash->notice( \Dsc\Lib\Debug::dump( $identity ) );
// Check if the user have permission to the current option
$actionName = $dispatcher->getActionName();
if (!$this->acl->isAllowed($identity['profile'], $controllerName, $actionName)) {
$this->flash->warning('You don\'t have access to: ' . $controllerName . ' : ' . $actionName);
if ($this->acl->isAllowed($identity['profile'], $controllerName, 'index')) {
$dispatcher->forward(array('controller' => $controllerName, 'action' => 'index'));
} else {
$dispatcher->forward(array('controller' => 'User_Control', 'action' => 'index'));
}
return false;
}
}
示例2: beforeExecuteRoute
/**
* @param Event $event
* @param MvcDispatcher $dispatcher
*/
public function beforeExecuteRoute(Event $event, MvcDispatcher $dispatcher)
{
if ($dispatcher->getNamespaceName() !== $dispatcher->getDefaultNamespace()) {
/** @var MvcView $view */
$view = $dispatcher->getDI()->get('view');
if ($view->isDisabled()) {
return;
}
$viewPathParts = array_values(array_diff(explode('\\', strtolower($dispatcher->getHandlerClass())), explode('\\', strtolower($dispatcher->getDefaultNamespace()))));
$viewPathParts[] = $dispatcher->getActionName();
$view->setLayout($viewPathParts[0]);
$view->pick(implode(DIRECTORY_SEPARATOR, $viewPathParts));
}
}
示例3: beforeDispatch
public function beforeDispatch(\Phalcon\Events\Event $event, Dispatcher $dispatcher)
{
$id = $this->session->get(self::SESSION_USER_ID);
$sessionKey = $this->session->get(self::SESSION_KEY);
$user = $this->getCurrentUser();
if ($id && $user) {
if (!$user->validateSessionKey($sessionKey)) {
$this->session->destroy();
$this->response->redirect('');
return false;
}
// Allow access when logged in
} else {
if ($dispatcher->getHandlerClass() === 'AuthController' && $dispatcher->getActionName() === 'login') {
// Permit the login action when not logged in
} else {
// Handle everything with /auth/login for guests
$dispatcher->forward(array('controller' => 'auth', 'action' => 'login'));
}
}
}