当前位置: 首页>>代码示例>>PHP>>正文


PHP Dispatcher::forward方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\Dispatcher::forward方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::forward方法的具体用法?PHP Dispatcher::forward怎么用?PHP Dispatcher::forward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\Dispatcher的用法示例。


在下文中一共展示了Dispatcher::forward方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeExecuteRoute

 /**
  * Execute before the router so we can determine if this is a provate 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();
     // Only check permissions on private controllers
     if ($this->acl->isPrivate($controllerName)) {
         // 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->flash->notice('You don\'t have access to this module: private');
             $dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
             return false;
         }
         // Check if the user have permission to the current option
         $actionName = $dispatcher->getActionName();
         if (!$this->acl->isAllowed($identity['profile'], $controllerName, $actionName)) {
             $this->flash->notice('You don\'t have access to this module: ' . $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;
         }
     }
 }
开发者ID:sbarrios,项目名称:exclie_soap,代码行数:33,代码来源:ControllerBase.php

示例2: 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;
     }
 }
开发者ID:fenghuilee,项目名称:writepress,代码行数:36,代码来源:BaseAuth.php

示例3: __construct

 public function __construct(Dispatcher $dispatcher, $exception)
 {
     if ($exception instanceof DispatchException) {
         $dispatcher->forward(array('module' => 'index', 'controller' => 'error', 'action' => 'error404'));
         return false;
     }
     $dispatcher->forward(array('module' => 'index', 'controller' => 'error', 'action' => 'error503'));
     return false;
 }
开发者ID:bitclaw,项目名称:phalcon-skeleton,代码行数:9,代码来源:ExceptionPlugin.php

示例4: beforeException

 public function beforeException(Event $event, Dispatcher $dispatcher, $exception)
 {
     //Handle 404 exceptions
     if ($exception instanceof DispatchException) {
         $dispatcher->forward(array('controller' => 'index', 'action' => 'show404'));
         return false;
     }
     //Handle other exceptions
     $dispatcher->forward(array('controller' => 'index', 'action' => 'show503'));
     return false;
 }
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:11,代码来源:dispatching-503.php

示例5: beforeException

 public function beforeException(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher, \Phalcon\Exception $exception)
 {
     switch ($exception->getCode()) {
         case $dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
         case $dispatcher::EXCEPTION_ACTION_NOT_FOUND:
             $dispatcher->forward(array('controller' => 'error', 'action' => 'notFound'));
             return false;
         default:
             $dispatcher->forward(array('controller' => 'error', 'action' => 'uncaughtException'));
             return false;
     }
 }
开发者ID:sb15,项目名称:phalcon-ext,代码行数:12,代码来源:ErrorHandlingPlugin.php

示例6: beforeException

 /**
  * This action is executed before execute any action in the application
  *
  * @param Event $event
  * @param Dispatcher $dispatcher
  */
 public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)
 {
     if ($exception instanceof DispatcherException) {
         switch ($exception->getCode()) {
             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                 $dispatcher->forward(array('controller' => 'errors', 'action' => 'show404'));
                 return false;
         }
     }
     $dispatcher->forward(array('controller' => 'errors', 'action' => 'show500'));
     return false;
 }
开发者ID:Kefir92,项目名称:home-bookkeeping,代码行数:19,代码来源:NotFoundPlugin.php

示例7: beforeException

 /**
  * This action is executed before execute any action in the application
  *
  * @param Event $event
  * @param MvcDispatcher $dispatcher
  * @param Exception $exception
  * @return boolean
  */
 public function beforeException(Event $event, MvcDispatcher $dispatcher, DispatcherException $exception)
 {
     error_log($exception->getMessage() . PHP_EOL . $exception->getTraceAsString());
     if ($exception instanceof DispatcherException) {
         switch ($exception->getCode()) {
             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                 $dispatcher->forward(array('controller' => 'error', 'action' => 'error404'));
                 return false;
         }
     }
     $dispatcher->forward(array('controller' => 'errors', 'action' => 'show500'));
     return false;
 }
开发者ID:nguyenthephuc,项目名称:phalcon_modules,代码行数:22,代码来源:NotFoundPlugin.php

示例8: beforeException

 /**
  * This action is executed before execute any action in the application
  *
  * @param Event               $event
  * @param Dispatcher          $dispatcher
  * @param DispatcherException $exception
  */
 public function beforeException(Event $event, MvcDispatcher $dispatcher, $exception)
 {
     $object = $event->getData();
     $this->view->setVar('message', $object->getMessage());
     switch ($exception->getCode()) {
         case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
         case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
             $dispatcher->forward(array('controller' => 'error', 'action' => 'show404'));
             return false;
         case Dispatcher::EXCEPTION_CYCLIC_ROUTING:
             $dispatcher->forward(['controller' => 'errors', 'action' => 'reports']);
             return false;
     }
 }
开发者ID:gitter-badger,项目名称:phanbook,代码行数:21,代码来源:NotFound.php

示例9: beforeDispatch

    public function beforeDispatch(Event $event, Dispatcher $dispatcher)
    {
        $di = PhDi::getDefault();
        // global config
        $config = $di['config'];
        // Take the active controller/action from the dispatcher
        $controller = $dispatcher->getControllerName();
        $action = $dispatcher->getActionName();
        // No ACL checks for AccessController
        if ($controller == 'access') {
            return true;
        }
        // Check whether the "auth" variable exists in session to define the active role
        $auth = $this->session->get('auth');
        if (!$auth) {
            // user not logged in
            $dispatcher->forward(array('controller' => 'access', 'action' => 'signin'));
            return false;
        } else {
            $role = $auth['role'];
        }
        // Check whether acl data already exist
        $aclFileName = $config->application['securityDir'] . "acl.data";
        if (!is_file($aclFileName)) {
            // Obtain the ACL list
            $acl = $this->getAcl();
            // Store serialized list into plain file
            file_put_contents($aclFileName, serialize($acl));
        } else {
            //Restore acl object from serialized file
            $acl = unserialize(file_get_contents($aclFileName));
        }
        // Check if the Role have access to the controller (resource)
        $allowed = $acl->isAllowed($role, $controller, $action);
        if ($allowed != Acl::ALLOW) {
            // If user doesn't have access forward to the index controller
            $flashMessage = <<<EOT
<div class="alert alert-block alert-danger">
    <a class="close" data-dismiss="alert" href="#">×</a>
    <h4 class="alert-heading">Error!</h4>
    You don't have access to this module.
</div>
EOT;
            $this->flashSession->warning($flashMessage);
            $dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
            // Returning "false" will tell to the dispatcher to stop the current operation
            return false;
        }
    }
开发者ID:hacktm15,项目名称:CityBox,代码行数:49,代码来源:Security.php

示例10: beforeException

 public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)
 {
     if ($exception instanceof DispatcherException) {
         switch ($exception->getCode()) {
             //en caso de que el servicio llamado no sea encontrado o la acción no se encuentre
             case PhDispatcher::EXCEPTION_HANDLER_NOT_FOUND:
             case PhDispatcher::EXCEPTION_ACTION_NOT_FOUND:
                 //con dispatcher->forward le decimos que muestre el contenido de la acción show404 del controlador error, a crearlo
                 $dispatcher->forward(array('controller' => 'error', 'action' => 'show404'));
                 return false;
         }
     }
     $dispatcher->forward(array('controller' => 'error', 'action' => 'show500'));
     return false;
 }
开发者ID:bodypheo,项目名称:Proyecto-Fin-de-Carrera,代码行数:15,代码来源:NotFoundPlugin.php

示例11: beforeExecuteRoute

 public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
 {
     $auth = $this->session->get('auth');
     if (!$auth) {
         $role = 'INVITADO';
     } else {
         $role = $auth["rol_nombre"];
     }
     //nombre del controlador al que intentamos acceder
     $controller = $dispatcher->getControllerName();
     //nombre de la acción a la que intentamos acceder
     $action = $dispatcher->getActionName();
     //obtenemos la Lista de Control de Acceso(acl) que hemos creado
     $acl = $this->getAcl();
     //boolean(true | false) si tenemos permisos devuelve true en otro caso false
     $allowed = $acl->isAllowed($role, $controller, $action);
     //si el usuario no tiene acceso a la zona que intenta acceder
     //se lo redirecciona a login. (o habria que enviarlo al index? )
     //con un mensaje flash
     if ($allowed != \Phalcon\Acl::ALLOW) {
         $this->flash->error("<p>ZONA RESTRINGIDA, NO TIENES PERMISO PARA ACCEDER A LA SECCIÓN SOLICITADA</p>");
         $dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
         return false;
     }
 }
开发者ID:munozdaniel,项目名称:sya,代码行数:25,代码来源:Seguridad.php

示例12: beforeDispatch

 public function beforeDispatch(Event $event, Dispatcher $dispatcher)
 {
     //check whether the 'auth' variable exists in session (if logged in)
     $auth = $this->session->get('auth');
     if ($auth) {
         //logged in
         $role = 'Users';
     } else {
         //not logged in
         $role = 'Guests';
     }
     //take the active controller/action from the dispatcher
     $controller = $dispatcher->getControllerName();
     $action = $dispatcher->getActionName();
     //obtain the ACL list
     $acl = $this->getAcl(false);
     //check if the role has access to the controller (resource)
     $allowed = $acl->isAllowed($role, $controller, $action);
     if ($allowed != Acl::ALLOW) {
         //does not have access to the controller, fwd to index
         $this->flashSession->error("{$role} don't have access to this page!");
         $dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
         //return false to tell dispatcher to stop current operation
         return false;
     } else {
         //user is allowed in (do nothing)
         if ($controller == 'admin' && $action == 'updateAcl') {
             //update acl
             $acl = $this->getAcl(true);
         }
     }
 }
开发者ID:freesaga,项目名称:getit,代码行数:32,代码来源:Security.php

示例13: beforeExecuteRoute

 /**
  * @param Dispatcher $dispatcher
  */
 public function beforeExecuteRoute(Dispatcher $dispatcher)
 {
     $controllerName = $dispatcher->getControllerName();
     $actionName = $dispatcher->getActionName();
     // This confirm a private zone
     //check for a closed controller and Action is exist a current session
     if ($this->acl->isClosed($controllerName, $actionName)) {
         if (!is_null($this->auth->getAccess())) {
             //This redirect to another Controller/Action
             $this->response->redirect('dashboard');
             // Disable the view to avoid rendering
             $this->view->disable();
         }
         return true;
     }
     if ($this->acl->isPrivate($controllerName)) {
         if (!is_null($this->auth->getAccess())) {
             //echo "Logeado";
         } else {
             //Display a error by a flash component
             $this->flash->notice('Upss! Access denied, Please Registry first or Login into Kangoo');
             //Execute the dispatcher to move above the user
             $dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
             return false;
         }
     }
 }
开发者ID:Pablo251,项目名称:Kangoo,代码行数:30,代码来源:ControllerBase.php

示例14: beforeDispatch

 /**
  * This action is executed before execute any action in the application
  */
 public function beforeDispatch(Event $event, Dispatcher $dispatcher)
 {
     if ($this->config->application->user_login_form_cookies) {
         //use cookies
         $auth = $this->_getCookie('auth');
         if (!$auth) {
             $role = 'Guests';
         } else {
             $role = $this->_getCookie('role');
             $role = 'Person';
         }
     } else {
         $auth = $this->session->get('auth');
         $auth = $this->_getCookie('auth');
         if (!$auth) {
             $role = 'Guests';
         } else {
             $role = $auth['role'];
             // $role='Common';
         }
     }
     $controller = $dispatcher->getControllerName();
     $action = $dispatcher->getActionName();
     $acl = $this->getAcl();
     $allowed = $acl->isAllowed($role, $controller, $action);
     if ($allowed != Acl::ALLOW) {
         $this->flash->error("You don't have access to this module");
         $dispatcher->forward(array('controller' => 'user', 'action' => 'login'));
         return false;
     }
 }
开发者ID:alexz202,项目名称:goldenlight,代码行数:34,代码来源:Security.php

示例15: beforeExecuteRoute

 /**
  * @param Dispatcher $dispatcher
  *
  * @return bool
  */
 public function beforeExecuteRoute(Dispatcher $dispatcher)
 {
     $returnVal = true;
     $lang = $this->getUriParameter('language');
     $controllerName = $dispatcher->getControllerName();
     if ('1' != $this->config->application->debug) {
         $lang = $this->getUriParameter('language');
         $lang = $lang ? $lang : 'en';
         $key = preg_replace('/[^a-zA-Z0-9\\_]/', '', $lang . '-' . $dispatcher->getControllerName() . '-' . $dispatcher->getActionName() . '-' . implode('-', $dispatcher->getParams()));
         $this->view->cache(array('key' => $key));
         if ($this->view->getCache()->exists($key)) {
             $returnVal = false;
         }
     }
     $auth = $this->session->get('auth');
     $identity = $this->auth->getIdentity();
     if (!$auth) {
         $role = 'Guests';
     } else {
         $role = $identity['profile'];
     }
     // Check if the user have permission to the current option
     $actionName = $dispatcher->getActionName();
     if (!$this->acl->isAllowed($role, $controllerName, $actionName)) {
         $this->flash->notice('You don\'t have access to this module: ' . $controllerName . ':' . $actionName);
         if ($this->acl->isAllowed($identity['profile'], $controllerName, 'index')) {
             $dispatcher->forward(array('controller' => $controllerName, 'action' => 'index'));
         }
         $returnVal = false;
     } else {
         $this->requestInitialize($controllerName);
     }
     return $returnVal;
 }
开发者ID:phil-schreiber,项目名称:messewebsite,代码行数:39,代码来源:ControllerBase.php


注:本文中的Phalcon\Mvc\Dispatcher::forward方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。