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


PHP Event\EventManager類代碼示例

本文整理匯總了PHP中Cake\Event\EventManager的典型用法代碼示例。如果您正苦於以下問題:PHP EventManager類的具體用法?PHP EventManager怎麽用?PHP EventManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: beforeRender

 /**
  * beforeRender event.
  *
  * @param Event $event Event.
  * @return void
  */
 public function beforeRender(Event $event)
 {
     $this->set('authUser', $this->authUser);
     $this->set('title', $this->name);
     $event = new Event('CakeAdmin.Controller.beforeRender', $this);
     EventManager::instance()->dispatch($event);
 }
開發者ID:cakemanager,項目名稱:cakephp-cakeadmin,代碼行數:13,代碼來源:AppController.php

示例2: _detachListeners

 /**
  * Unloads all registered listeners that were attached using the
  * "_attachListeners()" method.
  *
  * @return void
  */
 protected function _detachListeners()
 {
     $EventManager = EventManager::instance();
     foreach ($this->_listeners as $listener) {
         $EventManager->detach($listener);
     }
 }
開發者ID:quickapps-plugins,項目名稱:installer,代碼行數:13,代碼來源:ListenerHandlerTrait.php

示例3: setUp

 /**
  * startTest
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->ImageStorage = TableRegistry::get('Burzum/FileStorage.ImageStorage');
     $listener = new LocalListener();
     EventManager::instance()->on($listener);
 }
開發者ID:tiagocapelli,項目名稱:cakephp-file-storage,代碼行數:12,代碼來源:ImageStorageEntityTest.php

示例4: _before

 public function _before(TestCase $test)
 {
     if (method_exists($test, 'getTestClass')) {
         $this->testCase = $test->getTestClass();
     } else {
         $this->testCase = $test;
     }
     if (!isset($this->testCase->autoFixtures)) {
         $this->testCase->autoFixtures = $this->config['autoFixtures'];
     }
     if (!isset($this->testCase->dropTables)) {
         $this->testCase->dropTables = $this->config['dropTables'];
     }
     if (!isset($this->testCase->cleanUpInsertedRecords)) {
         $this->testCase->cleanUpInsertedRecords = $this->config['cleanUpInsertedRecords'];
     }
     EventManager::instance(new EventManager());
     $this->fixtureManager = new FixtureManager();
     if ($this->testCase->autoFixtures) {
         if (!isset($this->testCase->fixtures)) {
             $this->testCase->fixtures = [];
         }
         $this->loadFixtures($this->testCase->fixtures);
     }
     $this->snapshotApplication();
 }
開發者ID:cakephp,項目名稱:codeception,代碼行數:26,代碼來源:Framework.php

示例5: bake

 /**
  * {@inheritDoc}
  */
 public function bake($name)
 {
     EventManager::instance()->on('Bake.initialize', function (Event $event) {
         $event->subject->loadHelper('Migrations.Migration');
     });
     return parent::bake($name);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:10,代碼來源:MigrationTask.php

示例6: authorize

 /**
  * @return \Cake\Network\Response|void
  * @throws \League\OAuth2\Server\Exception\InvalidGrantException
  */
 public function authorize()
 {
     if (!($authParams = $this->OAuth->checkAuthParams('authorization_code'))) {
         return;
     }
     if (!$this->Auth->user()) {
         $query = $this->request->query;
         $query['redir'] = 'oauth';
         return $this->redirect(['plugin' => false, 'controller' => 'Users', 'action' => 'login', '?' => $query]);
     }
     $event = new Event('OAuthServer.beforeAuthorize', $this);
     EventManager::instance()->dispatch($event);
     if (is_array($event->result)) {
         $this->set($event->result);
     }
     if ($this->request->is('post') && $this->request->data['authorization'] === 'Approve') {
         $ownerModel = isset($this->request->data['owner_model']) ? $this->request->data['owner_model'] : 'Users';
         $ownerId = isset($this->request->data['owner_id']) ? $this->request->data['owner_id'] : $this->Auth->user('id');
         $redirectUri = $this->OAuth->Server->getGrantType('authorization_code')->newAuthorizeRequest($ownerModel, $ownerId, $authParams);
         $event = new Event('OAuthServer.afterAuthorize', $this);
         EventManager::instance()->dispatch($event);
         return $this->redirect($redirectUri);
     } elseif ($this->request->is('post')) {
         $event = new Event('OAuthServer.afterDeny', $this);
         EventManager::instance()->dispatch($event);
         $error = new AccessDeniedException();
         $redirectUri = new RedirectUri($authParams['redirect_uri'], ['error' => $error->errorType, 'message' => $error->getMessage()]);
         return $this->redirect($redirectUri);
     }
     $this->set('authParams', $authParams);
     $this->set('user', $this->Auth->user());
 }
開發者ID:surjit,項目名稱:oauth-server,代碼行數:36,代碼來源:OAuthController.php

示例7: testProcessVersion

 /**
  * testProcessVersion
  *
  * @return void
  */
 public function testProcessVersion()
 {
     $entity = $this->Image->newEntity(['foreign_key' => 'test-1', 'model' => 'Test', 'file' => ['name' => 'titus.jpg', 'size' => 332643, 'tmp_name' => Plugin::path('Burzum/FileStorage') . DS . 'tests' . DS . 'Fixture' . DS . 'File' . DS . 'titus.jpg', 'error' => 0]], ['accessibleFields' => ['*' => true]]);
     $this->Image->save($entity);
     $result = $this->Image->find()->where(['id' => $entity->id])->first();
     $this->assertTrue(!empty($result) && is_a($result, '\\Cake\\ORM\\Entity'));
     $this->assertTrue(file_exists($this->testPath . $result['path']));
     $path = $this->testPath . $result['path'];
     $Folder = new Folder($path);
     $folderResult = $Folder->read();
     $this->assertEquals(count($folderResult[1]), 3);
     Configure::write('FileStorage.imageSizes.Test', array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))));
     StorageUtils::generateHashes();
     $Event = new Event('ImageVersion.createVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200)))));
     EventManager::instance()->dispatch($Event);
     $path = $this->testPath . $result['path'];
     $Folder = new Folder($path);
     $folderResult = $Folder->read();
     $this->assertEquals(count($folderResult[1]), 4);
     $Event = new Event('ImageVersion.removeVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200)))));
     EventManager::instance()->dispatch($Event);
     $path = $this->testPath . $result['path'];
     $Folder = new Folder($path);
     $folderResult = $Folder->read();
     $this->assertEquals(count($folderResult[1]), 3);
 }
開發者ID:tiagocapelli,項目名稱:cakephp-file-storage,代碼行數:31,代碼來源:ImageStorageTableTest.php

示例8: setUp

 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $eventManagerInstance = EventManager::instance();
     parent::setUp();
     EventManager::instance($eventManagerInstance);
     $this->session(mockUserSession());
     include QUICKAPPS_CORE . '/config/routes_site.php';
 }
開發者ID:quickapps-plugins,項目名稱:cms,代碼行數:11,代碼來源:IntegrationTestCase.php

示例9: __construct

 /**
  * Constructor
  *
  * @param Request|null       $request
  * @param Response|null      $response
  * @param EventManager|null  $eventManager
  * @param array              $viewOptions
  */
 public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
 {
     if ($eventManager === null) {
         $eventManager = EventManager::instance();
     }
     $this->_templatePath = Configure::read('App.paths.templates')[0];
     parent::__construct($request, $response, $eventManager, $viewOptions);
 }
開發者ID:clthck,項目名稱:cakephp-jade,代碼行數:16,代碼來源:JadeView.php

示例10: handleEvents

 /**
  * Attaches to Event topics and attaches them to the corresponding event handlers
  *
  * @return void
  */
 public function handleEvents()
 {
     if (defined('PHPUNIT_TESTSUITE') == 1) {
         return;
     }
     $manager = EventManager::instance();
     $manager->attach([$this, 'onForgotPassword'], 'Users.forgot_password');
 }
開發者ID:wolfgang-braun,項目名稱:cake-relay,代碼行數:13,代碼來源:NotificationHandler.php

示例11: bake

 /**
  * {@inheritDoc}
  */
 public function bake($name)
 {
     $collection = $this->getCollection($this->connection);
     EventManager::instance()->on('Bake.initialize', function (Event $event) use($collection) {
         $event->subject->loadHelper('Migrations.Migration', ['collection' => $collection]);
     });
     return parent::bake($name);
 }
開發者ID:GrandFelix,項目名稱:migrations,代碼行數:11,代碼來源:MigrationSnapshotTask.php

示例12: start

 /**
  * @param WebsocketStartEvent $event
  */
 public function start(WebsocketStartEvent $event)
 {
     $this->pcntl = new PCNTL($event->getLoop());
     foreach ($this->signals as $signal) {
         $this->pcntl->on($signal, function ($signal) use($event) {
             EventManager::instance()->dispatch(SignalEvent::create($event->getLoop(), $signal));
         });
     }
 }
開發者ID:wyrihaximus,項目名稱:ratchet-pcntl,代碼行數:12,代碼來源:PcntlListener.php

示例13: getLinkTypes

 /**
  * Get available link types via an Event trigger
  * This fetches avilable Links from all activated Plugins.
  *
  * @return array
  */
 public function getLinkTypes()
 {
     $event = new Event('Wasabi.Backend.MenuItems.getLinkTypes', $this);
     EventManager::instance()->dispatch($event);
     $typeExternal = ['type' => 'external'];
     $typeCustom = ['type' => 'custom'];
     $event->result[__d('wasabi_core', 'General')] = [json_encode($typeExternal) => __d('wasabi_core', 'External Link'), json_encode($typeCustom) => __d('wasabi_core', 'Custom Controller Action')];
     return $event->result;
 }
開發者ID:wasabi-cms,項目名稱:cms,代碼行數:15,代碼來源:MenusTable.php

示例14: setUp

 /**
  * [setUp description]
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->resetReflectionCache();
     $this->_eventManager = EventManager::instance();
     $existing = Configure::read('App.paths.templates');
     $existing[] = Plugin::path('Crud') . 'tests/App/Template/';
     Configure::write('App.paths.templates', $existing);
 }
開發者ID:dgamboaestrada,項目名稱:cakephp-api,代碼行數:14,代碼來源:IntegrationTestCase.php

示例15: findAuth

 /**
  * Costum Auth finder method
  * 
  * @param array $config Table Configuration.
  *
  * @return void
  */
 public function findAuth(\Cake\ORM\Query $query, array $options)
 {
     $event = new Event('Lil.authFinder', $this, [$query, $options]);
     EventManager::instance()->dispatch($event);
     if (!empty($event->result)) {
         $query = $event->result;
     }
     return $query;
 }
開發者ID:malamalca,項目名稱:lil,代碼行數:16,代碼來源:UsersTable.php


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