當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractActionController::setEventManager方法代碼示例

本文整理匯總了PHP中Zend\Mvc\Controller\AbstractActionController::setEventManager方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractActionController::setEventManager方法的具體用法?PHP AbstractActionController::setEventManager怎麽用?PHP AbstractActionController::setEventManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Mvc\Controller\AbstractActionController的用法示例。


在下文中一共展示了AbstractActionController::setEventManager方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($event) use($controller) {
         /** @var \Zend\Http\Request $request */
         $request = $event->getRequest();
         $addresses = $request->getServer()->get('HTTP_X_FORWARDED_FOR');
         $addresses = explode(',', $addresses);
         $address = end($addresses);
         $address = trim($address);
         $user = $controller->getIdentityEntity();
         if (!is_null($user)) {
             $ip = $this->getEntityManager()->getRepository('NightsWatch\\Entity\\Ip')->findOneBy(['user' => $user, 'ip' => $address]);
             if (!$ip) {
                 $ip = new Ip();
                 $ip->ip = $address;
                 $ip->user = $user;
             }
             $ip->lastSeen = new \DateTime();
             $controller->getEntityManager()->persist($ip);
             try {
                 $controller->getEntityManager()->flush();
             } catch (\Exception $e) {
                 // The record already exists.  For now, do nothing.
             }
         }
     }, 100);
 }
開發者ID:jomo,項目名稱:TheNightsWatch2,代碼行數:29,代碼來源:ActionController.php

示例2: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($e) use($controller) {
         $route = $e->getRouteMatch();
         $params = $route->getParams();
         $request = $controller->getRequest();
         $has_access = false;
         if ($request->getUri()->getPath() === '/employee/signin') {
             $has_access = true;
         } else {
             $has_access = $controller->checkAuthentication('');
         }
         if ($has_access === false) {
             $e->stopPropagation();
         }
     }, 100);
     // execute before executing action logic
     $events->attach('dispatch', function ($e) use($controller) {
         $session = new Container('Auth');
         $controller->layout()->setVariable('page_title', $controller->getTitle());
     }, 0);
     return $this;
 }
開發者ID:DEVOP-TEAM,項目名稱:3.0-Zend,代碼行數:25,代碼來源:AbstractActionUnitedwebdesignsController.php

示例3: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $thisPtr = $this;
     $events->attach('dispatch', function ($e) use($thisPtr) {
         $adminIndex = $thisPtr->getServiceLocator()->get('Navigation')->findOneById(Constants::ADMIN_ID);
         $requirelogin = $thisPtr->getServiceLocator()->get('Navigation')->findAllBy("requireslogin", true);
         $authService = $thisPtr->getServiceLocator()->get('AdminAuthService');
         if ($authService->hasIdentity()) {
             $adminIndex->setVisible(true);
             $adminIndex->setLabel("Logout");
             $adminIndex->setAction("logout");
             foreach ($requirelogin as $rec) {
                 $thisPtr->getServiceLocator()->get('Navigation')->findOneById($rec->get("id"))->setVisible(true);
             }
         } else {
             $adminIndex->setVisible(false);
             $adminIndex->setLabel("Login");
             $adminIndex->setAction("index");
             foreach ($requirelogin as $rec) {
                 $thisPtr->getServiceLocator()->get('Navigation')->findOneById($rec->get("id"))->setVisible(false);
             }
             $controller = strtolower($thisPtr->params()->fromRoute('controller'));
             $action = strtolower($thisPtr->params()->fromRoute('action'));
             $unauthorizedAttempt = array_filter($requirelogin, function ($item) use($controller, $action) {
                 return strtolower($item->get("controller")) == $controller && strtolower($item->get("action")) == $action;
             });
             if (count($unauthorizedAttempt) > 0) {
                 return $thisPtr->redirect()->toUrl("/Index/index");
             }
         }
     }, 100);
     return $this;
 }
開發者ID:rmukras,項目名稱:ekda.org,代碼行數:34,代碼來源:BaseController.php

示例4: setEventManager

 /**
  * Changes the layout to layout/backupdb
  * @param EventManagerInterface $events
  */
 public function setEventManager(EventManagerInterface $events)
 {
     //Zend_Layout::getMvcInstance()->setLayout(__DIR__ . '/../view/layout/application.phtml');
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($e) use($controller) {
         $controller->layout('layout/backupdb');
     }, 100);
 }
開發者ID:parnustk,項目名稱:lisbackend,代碼行數:13,代碼來源:DumpController.php

示例5: setEventManager

 public function setEventManager(\Zend\EventManager\EventManagerInterface $events)
 {
     parent::setEventManager($events);
     // entity manager
     $this->em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     // auth
     $this->auth = $this->getServiceLocator()->get('AuthService');
     $this->auth->setEm($this->em);
 }
開發者ID:jaspermeijaard,項目名稱:event-intranet,代碼行數:9,代碼來源:IndexController.php

示例6: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($e) use($controller) {
         $session = new Container('Auth');
         $controller->layout()->setVariable('page_title', $controller->getTitle());
     }, 0);
     return $this;
 }
開發者ID:DEVOP-TEAM,項目名稱:3.0-Zend,代碼行數:10,代碼來源:AbstractActionUnitedwebdesignsControllerNoAuth.php

示例7: setEventManager

 /**
  * overriding setEventManager method of AbstractActionControler
  * to call the authentication on "dispatch"
  * @see Zend\Mvc\Controller.AbstractController::setEventManager()
  */
 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($e) use($controller) {
         if (is_callable(array($controller, 'verificaAuth'))) {
             call_user_func(array($controller, 'verificaAuth'));
         }
     }, 100);
 }
開發者ID:Jorgeley,項目名稱:Real-State,代碼行數:15,代碼來源:PadraoControllerSuporte.php

示例8: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $events->attach('dispatch', function ($e) {
         $request = $e->getRequest();
         if (!$request instanceof ConsoleRequest) {
             throw new \RuntimeException(sprintf('%s can only be executed in a console environment', __CLASS__));
         }
     }, 100);
     return $this;
 }
開發者ID:gsomoza,項目名稱:TimeTracking,代碼行數:11,代碼來源:DevelopmentModeController.php

示例9: setEventManager

 /**
  * Ensures that the actions in this controller can only be used if a user is authenticated.
  *
  * @param EventManagerInterface $events
  * @return $this|void|\Zend\Mvc\Controller\AbstractController
  */
 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($e) use($controller) {
         $sm = $e->getApplication()->getServiceManager();
         $auth = $sm->get('zfcuser_auth_service');
         if (!$auth->hasIdentity()) {
             return $controller->redirect()->toRoute('zfcuser/login');
         }
     }, 100);
     // execute before executing action logic
 }
開發者ID:rawatanil3,項目名稱:zf2forbeginners-old,代碼行數:19,代碼來源:FeedsController.php

示例10: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($e) use($controller) {
         $request = $e->getRequest();
         $method = $request->getMethod();
         if (!in_array($method, array('PUT', 'DELETE', 'PATCH'))) {
             //Init
             return $this->init();
         }
     }, 100);
     // execute before executing action logic
 }
開發者ID:ngen,項目名稱:zf2entity,代碼行數:14,代碼來源:EntityStatisticsController.php

示例11: setEventManager

 /**
  * @param EventManagerInterface $events
  * @return $this
  */
 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     /*
     $controller = $this;
     $events->attach('dispatch', function ($e) use ($controller) {
         $controller->layout('layout/admin');
         if ($controller->zfcUserAuthentication()->hasIdentity()) {
             var_dump($controller->zfcUserAuthentication()->getIdentity());
         }
     }, 100);
     */
     return $this;
 }
開發者ID:bedi,項目名稱:mfcc-admin-module,代碼行數:18,代碼來源:AdminModuleBaseController.php

示例12: setEventManager

 /**
  * Set event manager
  */
 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     // execute before executing action logic
     $events->attach('dispatch', function ($e) use($controller) {
         $request = $this->getRequest();
         // Make sure that we are running in a console and the user has not tricked our
         // application into running this action from a public web server.
         if (!$request instanceof ConsoleRequest) {
             return $this->notFoundAction();
         }
     }, 100);
 }
開發者ID:spooner77,項目名稱:dream-cms,代碼行數:17,代碼來源:ApplicationAbstractBaseConsoleController.php

示例13: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $this->setEm();
     $controller = $this;
     // PreDispatch
     $events->attach('dispatch', function ($e) use($controller) {
         $this->preDispath();
     }, 100);
     // PostDispatch
     $events->attach('dispatch', function ($e) use($controller) {
         $this->postDispatch();
     }, -100);
 }
開發者ID:elericuz,項目名稱:clearingservice,代碼行數:14,代碼來源:MainController.php

示例14: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     $events->attach('dispatch', function ($e) use($controller) {
         //Mảng tham số Router nhận được ở mỗi Action
         $this->_arrParam = $this->params()->fromRoute();
         //Mảng tham số Post nhận được ở mỗi Action
         $this->_arrPost = $this->params()->fromPost();
         //Đối tượng view Helper
         $this->_viewHelper = $this->getServiceLocator()->get('Zend\\View\\Renderer\\PhpRenderer');
         //Đường dẫn của Controller
         $paramController = $this->_arrParam['controller'];
         $tmp = explode("\\", $paramController);
         $this->_arrParam['module'] = strtolower($tmp[0]);
         //get module name
         $this->_arrParam['controller'] = strtolower($tmp[2]);
         //get controller name
         $this->_currentController = '/' . $this->_arrParam['module'] . '/' . $this->_arrParam['controller'];
         //Đường dẫn của Action chính
         $this->_actionMain = '/' . $this->_arrParam['module'] . '/' . $this->_arrParam['controller'] . '/' . $this->_arrParam['action'];
         //---------Dat ten SESSION-----------------------------------------
         $this->_namespace = $this->_arrParam['module'] . '_' . $this->_arrParam['controller'];
         $ssFilter = new Container($this->_namespace);
         if (empty($ssFilter->col)) {
             $ssFilter->keywords = '';
             $ssFilter->col = 'id';
             $ssFilter->order = 'DESC';
         }
         if (empty($ssFilter->record)) {
             $ssFilter->record = 10;
         }
         $this->_arrParam['ssFilter']['keywords'] = $ssFilter->keywords;
         $this->_arrParam['ssFilter']['sort'] = $ssFilter->sort;
         $this->_arrParam['ssFilter']['col'] = $ssFilter->col;
         $this->_arrParam['ssFilter']['order'] = $ssFilter->order;
         $this->_arrParam['ssFilter']['record'] = $ssFilter->record;
         $this->_arrParam['ssFilter']['field'] = $ssFilter->field;
         $this->_arrParam['ssFilter']['status'] = $ssFilter->status;
         $this->_arrParam['ssFilter']['group'] = $ssFilter->group;
         $this->_arrParam['ssFilter']['city'] = $ssFilter->city;
         $this->_paginatorParams['itemCountPerPage'] = (int) $ssFilter->record;
         $this->_paginatorParams['currentPageNumber'] = $this->params()->fromRoute('page', 1);
         $this->_arrParam['paginator'] = $this->_paginatorParams;
         //Load templates
         $this->layout('layout/home');
     }, 100);
     // execute before executing action logic
 }
開發者ID:quangdungninh,項目名稱:zendvnteam,代碼行數:49,代碼來源:MapApiController.php

示例15: setEventManager

 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $self = $this;
     $events->attach('dispatch', function ($e) use($self) {
         $self->controller = $self->params()->fromRoute('controller');
         $self->action = $self->params()->fromRoute('action');
         $self->p1 = $self->params()->fromRoute('p1');
         $self->p2 = $self->params()->fromRoute('p2');
         $self->p3 = $self->params()->fromRoute('p3');
         $self->p4 = $self->params()->fromRoute('p4');
         $self->setPermissions($self);
     }, 100);
     return $this;
 }
開發者ID:rmukras,項目名稱:coffee,代碼行數:15,代碼來源:BaseController.php


注:本文中的Zend\Mvc\Controller\AbstractActionController::setEventManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。