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


PHP MvcEvent::setControllerClass方法代码示例

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


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

示例1: testShouldCache

 /**
  * @param array   $controllers
  * @param string  $requestedController
  * @param boolean $expectedResult
  * @dataProvider shouldCacheProvider
  */
 public function testShouldCache($controllers, $requestedController, $expectedResult)
 {
     $this->strategy->setControllers($controllers);
     $mvcEvent = new MvcEvent();
     $mvcEvent->setControllerClass($requestedController);
     $mvcEvent->setRouteMatch(new RouteMatch(array('controller' => $requestedController)));
     $this->assertEquals($expectedResult, $this->strategy->shouldCache($mvcEvent));
 }
开发者ID:stefanorg,项目名称:zf2-fullpage-cache,代码行数:14,代码来源:ControllerTest.php

示例2: onRoute

 /**
  * Global Route /module/controller/action
  * @param MvcEvent $e
  */
 public function onRoute(MvcEvent $e)
 {
     $matches = $e->getRouteMatch();
     $module = $matches->getParam('module');
     $controller = $matches->getParam('controller');
     if ($module && $controller && strpos($controller, '\\') === false) {
         $matches->setParam(self::ORIGINAL_CONTROLLER, $controller);
         $controllerLoader = $e->getApplication()->getServiceManager()->get('ControllerManager');
         $ctrlClass = $this->convertName($module) . '\\Controller\\';
         $ctrlClass .= $this->convertName($controller);
         $controller = $ctrlClass;
         $matches->setParam('controller', $controller);
         $ctrlClass .= 'Controller';
         if (!$controllerLoader->has($controller) && class_exists($ctrlClass)) {
             $controllerLoader->setInvokableClass($controller, $ctrlClass);
             $e->setController($controller);
             $e->setControllerClass($ctrlClass);
         }
     }
 }
开发者ID:cityware,项目名称:city-mvc,代码行数:24,代码来源:GlobalRouteListenerController.php

示例3: test404ResponsePrepares404ViewModelWithControllerWhenAllowed

 public function test404ResponsePrepares404ViewModelWithControllerWhenAllowed()
 {
     $response = new Response();
     $event = new MvcEvent();
     $controller = 'some-or-other';
     $controllerClass = 'Some\\Controller\\OrOtherController';
     $event->setController($controller);
     $event->setControllerClass($controllerClass);
     foreach (array('setDisplayNotFoundReason', 'setDisplayExceptions') as $method) {
         foreach (array(true, false) as $allow) {
             $this->strategy->{$method}($allow);
             $response->setStatusCode(404);
             $event->setResult(null);
             $event->setResponse($response);
             $this->strategy->prepareNotFoundViewModel($event);
             $model = $event->getResult();
             $this->assertInstanceOf('Zend\\View\\Model\\ModelInterface', $model);
             $variables = $model->getVariables();
             if ($allow) {
                 $this->assertTrue(isset($variables['controller']));
                 $this->assertEquals($controller, $variables['controller']);
                 $this->assertTrue(isset($variables['controller_class']));
                 $this->assertEquals($controllerClass, $variables['controller_class']);
             } else {
                 $this->assertFalse(isset($variables['controller']));
                 $this->assertFalse(isset($variables['controller_class']));
             }
         }
     }
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:30,代码来源:RouteNotFoundStrategyTest.php

示例4: marshalMiddlewareNotCallable

 /**
  * Marshal a middleware not callable exception event
  *
  * @param  string $type
  * @param  string $middlewareName
  * @param  MvcEvent $event
  * @param  Application $application
  * @param  \Exception $exception
  * @return mixed
  */
 protected function marshalMiddlewareNotCallable($type, $middlewareName, MvcEvent $event, Application $application, \Exception $exception = null)
 {
     $event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
     $event->setError($type);
     $event->setController($middlewareName);
     $event->setControllerClass('Middleware not callable: ' . $middlewareName);
     if ($exception !== null) {
         $event->setParam('exception', $exception);
     }
     $events = $application->getEventManager();
     $results = $events->triggerEvent($event);
     $return = $results->last();
     if (!$return) {
         $return = $event->getResult();
     }
     return $return;
 }
开发者ID:kuisatz,项目名称:ustalarMerkezi,代码行数:27,代码来源:MiddlewareListener.php

示例5: marshalControllerNotFoundEvent

 /**
  * Marshal a controller not found exception event
  *
  * @param  string $type
  * @param  string $controllerName
  * @param  MvcEvent $event
  * @param  Application $application
  * @param  \Throwable|\Exception $exception
  * @return mixed
  */
 protected function marshalControllerNotFoundEvent($type, $controllerName, MvcEvent $event, Application $application, $exception = null)
 {
     $event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
     $event->setError($type);
     $event->setController($controllerName);
     $event->setControllerClass('invalid controller class or alias: ' . $controllerName);
     if ($exception !== null) {
         $event->setParam('exception', $exception);
     }
     $events = $application->getEventManager();
     $results = $events->triggerEvent($event);
     $return = $results->last();
     if (!$return) {
         $return = $event->getResult();
     }
     return $return;
 }
开发者ID:zendframework,项目名称:zend-mvc,代码行数:27,代码来源:DispatchListener.php


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