當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。