当前位置: 首页>>代码示例>>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;未经允许,请勿转载。