本文整理汇总了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);
}
示例2: onDispatch
/**
* @param \Zend\Mvc\MvcEvent $e
*/
public function onDispatch(MvcEvent $e)
{
$layout = $this->layout();
$layout->setTemplate('default/layout');
$layout->bodyCls = '';
parent::onDispatch($e);
}
示例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);
}
示例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)) {
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例9: onDispatch
public function onDispatch(\Zend\Mvc\MvcEvent $e)
{
parent::onDispatch($e);
$routeMatch = $e->getRouteMatch();
$ar = $routeMatch->getParams();
// $this->accesslLog();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例14: onDispatch
public function onDispatch(\Zend\Mvc\MvcEvent $e)
{
$sessionUser = new container('user');
if (!$sessionUser->connected) {
$this->redirect()->toRoute('home');
}
return parent::onDispatch($e);
}
示例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);
}