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


PHP Controller::eventManager方法代码示例

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


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

示例1: testInnerComponentsAreNotEnabled

 /**
  * test that component components are not enabled in the collection.
  *
  * @return void
  */
 public function testInnerComponentsAreNotEnabled()
 {
     $mock = $this->getMock('Cake\\Event\\EventManager');
     $controller = new Controller();
     $controller->eventManager($mock);
     $mock->expects($this->once())->method('on')->with($this->isInstanceOf('TestApp\\Controller\\Component\\AppleComponent'));
     $Collection = new ComponentRegistry($controller);
     $Apple = $Collection->load('Apple');
     $this->assertInstanceOf('TestApp\\Controller\\Component\\OrangeComponent', $Apple->Orange, 'class is wrong');
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:15,代码来源:ComponentTest.php

示例2: __construct

 /**
  * Constructor.
  *
  * @param \Cake\Controller\Controller $Controller Controller instance.
  */
 public function __construct(Controller $Controller = null)
 {
     if ($Controller) {
         $this->_Controller = $Controller;
         $this->eventManager($Controller->eventManager());
     }
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:12,代码来源:ComponentRegistry.php

示例3: __construct

 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $collection Component Registry
  * @param array $config Array of configuration settings.
  */
 public function __construct(ComponentRegistry $collection, $config = [])
 {
     $this->_controller = $collection->getController();
     $this->_eventManager = $this->_controller->eventManager();
     parent::__construct($collection, $config);
     $this->_createCrudComponentInstance();
 }
开发者ID:cakeplugins,项目名称:api,代码行数:13,代码来源:ApiBuilderComponent.php

示例4: __construct

 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $collection A ComponentCollection this component
  *   can use to lazy load its components.
  * @param array $config Array of configuration settings.
  */
 public function __construct(ComponentRegistry $collection, $config = [])
 {
     $config += ['actions' => [], 'listeners' => []];
     $config['actions'] = $this->normalizeArray($config['actions']);
     $config['listeners'] = $this->normalizeArray($config['listeners']);
     $this->_controller = $collection->getController();
     $this->_eventManager = $this->_controller->eventManager();
     parent::__construct($collection, $config);
 }
开发者ID:i3i2ain,项目名称:crud,代码行数:16,代码来源:CrudComponent.php

示例5: controllerSpy

 /**
  * Add additional event spies to the controller/view event manager.
  *
  * @param \Cake\Event\Event $event A dispatcher event.
  * @return void
  */
 public function controllerSpy($event)
 {
     if (empty($event->data['controller'])) {
         return;
     }
     $this->_controller = $event->data['controller'];
     $events = $this->_controller->eventManager();
     $events->attach(function ($event, $viewFile) {
         $this->_viewName = $viewFile;
     }, 'View.beforeRender');
     $events->attach(function ($event, $viewFile) {
         $this->_layoutName = $viewFile;
     }, 'View.beforeLayout');
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:20,代码来源:IntegrationTestCase.php

示例6: testRedirectBeforeRedirectListenerReturnFalse

 /**
  * test that beforeRedirect callback returning false in controller
  *
  * @return void
  */
 public function testRedirectBeforeRedirectListenerReturnFalse()
 {
     $Response = $this->getMock('Cake\\Network\\Response', ['stop', 'header']);
     $Controller = new Controller(null, $Response);
     $Controller->eventManager()->attach(function ($event, $url, $response) {
         return false;
     }, 'Controller.beforeRedirect');
     $Controller->response->expects($this->never())->method('stop');
     $Controller->response->expects($this->never())->method('header');
     $Controller->response->expects($this->never())->method('statusCode');
     $result = $Controller->redirect('http://cakephp.org');
     $this->assertNull($result);
 }
开发者ID:malhan23,项目名称:assignment-3,代码行数:18,代码来源:ControllerTest.php

示例7: setController

 /**
  * Set the controller associated with the collection.
  *
  * @param \Cake\Controller\Controller $controller Controller instance.
  * @return void
  */
 public function setController(Controller $controller)
 {
     $this->_Controller = $controller;
     $this->eventManager($controller->eventManager());
 }
开发者ID:lhas,项目名称:pep,代码行数:11,代码来源:ComponentRegistry.php

示例8: testRedirectBeforeRedirectListenerReturnResponse

 public function testRedirectBeforeRedirectListenerReturnResponse()
 {
     $Response = $this->getMockBuilder('Cake\\Network\\Response')->setMethods(['stop', 'header', 'statusCode'])->getMock();
     $Controller = new Controller(null, $Response);
     $newResponse = new Response();
     $Controller->eventManager()->on('Controller.beforeRedirect', function ($event, $url, $response) use($newResponse) {
         return $newResponse;
     });
     $result = $Controller->redirect('http://cakephp.org');
     $this->assertSame($newResponse, $result);
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:11,代码来源:ControllerTest.php


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