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


PHP AbstractActionController::onDispatch方法代码示例

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


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

示例1: onDispatch

 /**
  * @param MvcEvent $event
  *
  * @return parent::onDispatch
  */
 public function onDispatch(MvcEvent $event)
 {
     $request = $event->getRequest();
     $remoteAddr = $request->getServer('REMOTE_ADDR');
     // check IP address is allowed
     $application = $event->getApplication();
     $config = $application->getConfig();
     $autoDeployConfig = $config['auto_deploy'];
     $allowedIpAddresses = $autoDeployConfig['ipAddresses'];
     // error if ip is not allowed
     if (!in_array($remoteAddr, $allowedIpAddresses, true)) {
         $baseModel = new \Zend\View\Model\ViewModel();
         $baseModel->setTemplate('layout/output');
         $model = new \Zend\View\Model\ViewModel();
         $model->setTemplate('error/403');
         $baseModel->addChild($model);
         $baseModel->setTerminal(true);
         $event->setViewModel($baseModel);
         $response = $event->getResponse();
         $response->setStatusCode(403);
         $response->sendHeaders();
         $event->setResponse($response);
         exit;
     }
     return parent::onDispatch($event);
 }
开发者ID:totallydave,项目名称:auto-deploy,代码行数:31,代码来源:Zf2Controller.php

示例2: onDispatch

 /**
  * @param \Zend\Mvc\MvcEvent $e
  */
 public function onDispatch(MvcEvent $e)
 {
     $layout = $this->layout();
     $layout->setTemplate('default/layout');
     $layout->bodyCls = '';
     parent::onDispatch($e);
 }
开发者ID:socialog,项目名称:socialog,代码行数:10,代码来源:AbstractController.php

示例3: onDispatch

 public function onDispatch(\Zend\Mvc\MvcEvent $event)
 {
     self::$instance = $this;
     if (!isset($_COOKIE['language'])) {
         $headers = $this->getRequest()->getHeaders();
         $defaultLanguage = 'en';
         $supportedLanguages = array('en', 'pl');
         $match = false;
         $this->setLanguage($defaultLanguage);
         setcookie('language', $this->getLanguage(), time() + 60 * 60 * 24 * 365, '/');
     } else {
         $this->setLanguage($_COOKIE['language']);
         setcookie('language', $this->getLanguage(), time() + 60 * 60 * 24 * 365, '/');
     }
     $referer = $this->getRequest()->getHeader('Referer');
     if ($referer) {
         $referer = $referer->uri()->getPath();
     } else {
         $referer = '/';
     }
     $request = $this->getRequest();
     $response = $this->getResponse();
     if ($request->getHeaders()->get('Cookie') !== false && isset($request->getHeaders()->get('Cookie')->previous_link)) {
         $this->setPreviousLink($request->getHeaders()->get('Cookie')->previous_link);
     } else {
         $cookie = new SetCookie('previous_link', $referer, time() + 3600);
         $response->getHeaders()->addHeader($cookie);
         $this->setPreviousLink($referer);
     }
     parent::onDispatch($event);
 }
开发者ID:nmnb18,项目名称:Aufri.com,代码行数:31,代码来源:AbstractAppController.php

示例4: onDispatch

use Zend\Barcode\Barcode;
//added by Yesh
class UserController extends AbstractActionController
{
    protected $em;
    protected $authservice;
    public function onDispatch(MvcEvent $e)
    {
        /* Set Default layout for all the actions */
        $this->layout('layout/layout');
        $em = $this->getEntityManager();
        $cities = $em->getRepository('\\Admin\\Entity\\City')->findBy(array('countryId' => 2));
        $categories = $em->getRepository('\\Admin\\Entity\\Categories')->findBy(array('status' => 1));
        $this->layout()->cities = $cities;
        $this->layout()->categories = $categories;
        $user_session = new Container('user');
        $userid = $user_session->userId;
        if (empty($userid)) {
            return $this->redirect()->toRoute('home');
        } else {
            $msg = 'You are already logged in.';
            $status = 1;
            $this->layout()->setVariable('userId', $user_session->userId);
            $this->layout()->setVariable('username', $user_session->userName);
            $username = $user_session->userName;
            $tmp_user = $em->getRepository('\\Admin\\Entity\\Users')->find($user_session->userId);
            $city = $tmp_user->getCity();
            if (!empty($city)) {
开发者ID:sathishkumarb,项目名称:ttitstest,代码行数:28,代码来源:UserController.php

示例5: onDispatch

 public function onDispatch(MvcEvent $e)
 {
     if (!$this->getRequest() instanceof ConsoleRequest) {
         throw new \RuntimeException('You can only use this action from a console!');
     }
     return parent::onDispatch($e);
 }
开发者ID:ycheukf,项目名称:migration,代码行数:7,代码来源:MigrateController.php

示例6: onDispatch

 /**
  * check if the admin is login otherwise redirect it to login page
  **/
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     if (!isset($this->container->admin_id)) {
         return $this->redirect()->toRoute('adminlogin');
     }
     return parent::onDispatch($e);
 }
开发者ID:nidhimanrti,项目名称:Zend-Sample-Code,代码行数:10,代码来源:CmspageController.php

示例7: onDispatch

 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $install = setupUtility::checkInstall();
     if ($install == true) {
         return $this->redirect()->toRoute('install');
     }
     //get doctrine service
     $this->serviceLocatorStr = 'doctrine';
     $this->sm = $this->getServiceLocator();
     $this->doctrineService = $this->sm->get($this->serviceLocatorStr);
     //get translate service
     $this->translator = Utility::translate();
     //check login
     $user = Utility::checkLogin();
     if (!is_object($user) && $user == 0) {
         $this->redirect()->toRoute('frontend/child', array('controller' => 'login'));
     }
     //start acl
     //        $acl = new myAcl();
     //        $currentRoute  =  $this->getModuleCurrentRoute($e);
     //        $isOk = $acl->checkRole(UtilityRoleLevel::convertUserTypeToRole($user->userType)['role'],$currentRoute);
     //        if(!$isOk || $isOk == '' || $isOk == null){
     //           return $this->redirect()->toRoute('frontend/child', array('controller' => 'login'));
     //        }
     //end check login
     //end acl
     $this->init();
     return parent::onDispatch($e);
 }
开发者ID:binnguyen,项目名称:kaffacoffee,代码行数:29,代码来源:FrontEndController.php

示例8: onDispatch

 /**
  * @param \Zend\Mvc\MvcEvent $e
  * @return mixed
  */
 public function onDispatch(MvcEvent $e, $validate = true)
 {
     if ($validate && !$this->getServiceLocator()->get('ServiceLocator')->hasIdentity()) {
         $this->redirect()->toRoute(self::ROUTE_DEFAULT);
     }
     return parent::onDispatch($e);
 }
开发者ID:augustoalvess,项目名称:dataware,代码行数:11,代码来源:Controller.php

示例9: onDispatch

 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     parent::onDispatch($e);
     $routeMatch = $e->getRouteMatch();
     $ar = $routeMatch->getParams();
     // $this->accesslLog();
 }
开发者ID:hejames,项目名称:jTrMuzik,代码行数:7,代码来源:jMusicAbstractActionController.php

示例10: onDispatch

 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     //$logged_block = array('index');
     //if(!$this->identity() && !in_array($e->getRouteMatch()->getParam("action"), $logged_block)) return $this->redirect()->toRoute('home');
     die("Em Manutenção.");
     return parent::onDispatch($e);
 }
开发者ID:secretrepository,项目名称:consultoria,代码行数:7,代码来源:ChatController.php

示例11: onDispatch

 /**
  * Seta variáveis para o layout
  */
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     /**
      * Chamada do parent no inicio do método para primeiro setar
      * os valores das variáveis antes de renderizar a tela
      */
     parent::onDispatch($e);
 }
开发者ID:adaoex,项目名称:zf2-base,代码行数:11,代码来源:BaseController.php

示例12: onDispatch

 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $this->authService = new AuthenticationService();
     if (!$this->authService->hasIdentity()) {
         $this->redirect()->toRoute("auth");
     }
     return parent::onDispatch($e);
 }
开发者ID:ingzepe,项目名称:BaseProyect,代码行数:8,代码来源:IndexController.php

示例13: onDispatch

 /**
  * (non-PHPdoc)
  * @see \Zend\Mvc\Controller\AbstractActionController::onDispatch()
  */
 public function onDispatch(MvcEvent $event)
 {
     $request = $event->getRequest();
     if (!$request instanceof HttpRequest || !$request->isXmlHttpRequest()) {
         //throw new \RuntimeException('This controller must only be called with ajax requests.');
     }
     return parent::onDispatch($event);
 }
开发者ID:vfulco,项目名称:YAWIK,代码行数:12,代码来源:CommentController.php

示例14: onDispatch

 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $sessionUser = new container('user');
     if (!$sessionUser->connected) {
         $this->redirect()->toRoute('home');
     }
     return parent::onDispatch($e);
 }
开发者ID:edri,项目名称:EasyGoing,代码行数:8,代码来源:ProjectsController.php

示例15: onDispatch

 public function onDispatch(MvcEvent $e)
 {
     $logged_block = array('view', 'all');
     if (!$this->identity() && !in_array($e->getRouteMatch()->getParam("action"), $logged_block)) {
         return $this->redirect()->toRoute('home');
     }
     return parent::onDispatch($e);
 }
开发者ID:secretrepository,项目名称:consultoria,代码行数:8,代码来源:NewsController.php


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