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


PHP EventManager::off方法代碼示例

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


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

示例1: removeListener

 /**
  * Remove a listener from Crud.
  *
  * This will also detach it from the EventManager if it's attached.
  *
  * @param string $name Name
  * @return bool
  */
 public function removeListener($name)
 {
     $listeners = $this->config('listeners');
     if (!array_key_exists($name, $listeners)) {
         return false;
     }
     if (isset($this->_listenerInstances[$name])) {
         $this->_eventManager->off($this->_listenerInstances[$name]);
         unset($this->_listenerInstances[$name]);
     }
     unset($listeners[$name]);
     $this->_config['listeners'] = $listeners;
 }
開發者ID:i3i2ain,項目名稱:crud,代碼行數:21,代碼來源:CrudComponent.php

示例2: testRemoveAllListeners

 /**
  * Tests off'ing all listeners for an event
  */
 public function testRemoveAllListeners()
 {
     $manager = new EventManager();
     $manager->on('fake.event', ['AClass', 'aMethod']);
     $manager->on('another.event', ['priority' => 1], 'fakeFunction');
     $manager->off('fake.event');
     $expected = [['callable' => 'fakeFunction']];
     $this->assertEquals($expected, $manager->listeners('another.event'));
     $this->assertEquals([], $manager->listeners('fake.event'));
 }
開發者ID:Slayug,項目名稱:castor,代碼行數:13,代碼來源:EventManagerTest.php

示例3: off

 /**
  * Removes a listener from the active listeners.
  *
  * @param \Cake\Event\EventListenerInterface|string $eventKey
  * @param null $callable
  * @return void
  */
 public function off($eventKey, $callable = null)
 {
     if (is_object($callable)) {
         $key = get_class($callable);
         unset($this->_listenersMap[$key]);
     }
     parent::off($eventKey, $callable);
 }
開發者ID:Cheren,項目名稱:union,代碼行數:15,代碼來源:EventManager.php


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