本文整理汇总了PHP中EventManager::detachListener方法的典型用法代码示例。如果您正苦于以下问题:PHP EventManager::detachListener方法的具体用法?PHP EventManager::detachListener怎么用?PHP EventManager::detachListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventManager
的用法示例。
在下文中一共展示了EventManager::detachListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDetachListener4
/**
* detach a callable directly
*
* @covers Phossa\Event\EventManager::detachListener
*/
public function testDetachListener4()
{
$callable = function (Event $evt) {
$evt->setProperty('xxx', 'bingo');
return 10;
};
// detach a callable directly
$this->object->attachListener($callable, 'xSpecialEvent');
$this->assertTrue(1 === count($this->object->getEventNames()));
$this->object->detachListener($callable);
$this->assertTrue(0 === count($this->object->getEventNames()));
}
示例2: testListener
public function testListener()
{
$subject1 = $this->getMockBuilder('Jivoo\\Core\\EventSubject')->getMock();
$subject1->method('getEvents')->willReturn(array('someEvent'));
$subject2 = $this->getMockBuilder('Jivoo\\Core\\EventSubject')->getMock();
$subject2->method('getEvents')->willReturn(array('someEvent'));
$em1 = new EventManager($subject1);
$em2 = new EventManager($subject2, $em1);
$l = $this->getMockBuilder('Jivoo\\Core\\EventListener')->setMethods(array('getEventHandlers', 'someEvent'))->getMock();
$l->method('getEventHandlers')->wilLReturn(array(get_class($subject2) . '.someEvent'));
$l->expects($this->once())->method('someEvent')->willReturn(false);
$em1->attachListener($l);
$this->assertFalse($em2->trigger('someEvent'));
$em1->detachListener($l);
$this->assertTrue($em2->trigger('someEvent'));
}
示例3: detachEventListener
/**
* {@inheritdoc}
*/
public function detachEventListener(EventListener $listener)
{
$this->e->detachListener($listener);
}