本文整理汇总了PHP中Symfony\Component\EventDispatcher\EventDispatcher::hasListeners方法的典型用法代码示例。如果您正苦于以下问题:PHP EventDispatcher::hasListeners方法的具体用法?PHP EventDispatcher::hasListeners怎么用?PHP EventDispatcher::hasListeners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\EventDispatcher\EventDispatcher
的用法示例。
在下文中一共展示了EventDispatcher::hasListeners方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDispatcherHasListener
public function testDispatcherHasListener()
{
$this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::PRE_PAYMENT_SUCCESS));
$this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::PRE_PAYMENT_FAILED));
$this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::POST_PAYMENT_SUCCESS));
$this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::POST_PAYMENT_FAILED));
}
示例2: testBootShouldAddListenerToDispatcher
/**
* @return void
*/
public function testBootShouldAddListenerToDispatcher()
{
$application = new Application();
$dispatcher = new EventDispatcher();
$application['dispatcher'] = $dispatcher;
$serviceProvider = new KernelLogServiceProvider();
$serviceProvider->boot($application);
$this->assertTrue($dispatcher->hasListeners('kernel.request'));
$this->assertTrue($dispatcher->hasListeners('kernel.response'));
}
示例3: testHasListeners
public function testHasListeners()
{
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
$this->assertFalse($dispatcher->hasListeners('foo'));
$this->assertFalse($tdispatcher->hasListeners('foo'));
$tdispatcher->addListener('foo', $listener = function () {
});
$this->assertTrue($dispatcher->hasListeners('foo'));
$this->assertTrue($tdispatcher->hasListeners('foo'));
}
示例4: testGetHasListeners
public function testGetHasListeners()
{
$dispatcher = new EventDispatcher();
$this->assertFalse($dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener');
$dispatcher->connect('foo', 'listenToFoo');
$this->assertEquals(true, $dispatcher->hasListeners('foo'), '->hasListeners() returns true if the event has some listeners');
$dispatcher->disconnect('foo', 'listenToFoo');
$this->assertFalse($dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener');
$dispatcher->connect('bar', 'listenToBar');
$this->assertEquals(array('listenToBar'), $dispatcher->getListeners('bar'), '->getListeners() returns an array of listeners connected to the given event name');
$this->assertEquals(array(), $dispatcher->getListeners('foobar'), '->getListeners() returns an empty array if no listener are connected to the given event name');
}
示例5: removeSignalListener
public function removeSignalListener($signal, $callable)
{
$this->dispatcher->removeListener('morker.signal.' . $signal, $callable);
if (!$this->dispatcher->hasListeners('morker.signal.' . $signal)) {
pcntl_signal($signal, SIG_DFL);
}
}
示例6: hasListeners
/**
* @see EventDispatcherInterface::hasListeners
*/
public function hasListeners($eventName = null)
{
if (null === $eventName) {
return (bool) count($this->listenerIds) || (bool) count($this->listeners);
}
if (isset($this->listenerIds[$eventName])) {
return true;
}
return parent::hasListeners($eventName);
}
示例7: testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled
public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled()
{
$this->assertFalse($this->dispatcher->hasListeners('foo'));
$this->assertFalse($this->dispatcher->hasListeners());
}
示例8: it_asks_both_the_symfony_and_laravel_dispatcher_if_it_has_a_listener
/** @test */
public function it_asks_both_the_symfony_and_laravel_dispatcher_if_it_has_a_listener()
{
$this->symfony->hasListeners(static::EVENT)->willReturn(false);
$this->laravel->hasListeners(static::EVENT)->willReturn(false);
$this->assertFalse($this->dispatcher->hasListeners(static::EVENT));
}
示例9: testWorkaroundForPhpBug62976
/**
* @see https://bugs.php.net/bug.php?id=62976
*
* This bug affects:
* - The PHP 5.3 branch for versions < 5.3.18
* - The PHP 5.4 branch for versions < 5.4.8
* - The PHP 5.5 branch is not affected
*/
public function testWorkaroundForPhpBug62976()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener('bug.62976', new CallableClass());
$dispatcher->removeListener('bug.62976', function () {
});
$this->assertTrue($dispatcher->hasListeners('bug.62976'));
}
示例10: hasListeners
public function hasListeners($eventName = null)
{
return $this->eventDispatcher->hasListeners($eventName);
}