当前位置: 首页>>代码示例>>PHP>>正文


PHP EventDispatcher::hasListeners方法代码示例

本文整理汇总了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));
 }
开发者ID:krixer,项目名称:ServiredBundle,代码行数:7,代码来源:EventListenerTest.php

示例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'));
 }
开发者ID:spryker,项目名称:Application,代码行数:13,代码来源:KernelLogServiceProviderTest.php

示例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'));
 }
开发者ID:marchyoung,项目名称:FrameworkBenchmarks,代码行数:11,代码来源:TraceableEventDispatcherTest.php

示例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');
 }
开发者ID:netixpro,项目名称:symfony,代码行数:12,代码来源:EventDispatcherTest.php

示例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);
     }
 }
开发者ID:gcds,项目名称:morker,代码行数:7,代码来源:Master.php

示例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);
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:13,代码来源:ContainerAwareEventDispatcher.php

示例7: testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled

 public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled()
 {
     $this->assertFalse($this->dispatcher->hasListeners('foo'));
     $this->assertFalse($this->dispatcher->hasListeners());
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:5,代码来源:AbstractEventDispatcherTest.php

示例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));
 }
开发者ID:luizpcam,项目名称:laravel,代码行数:7,代码来源:AbstractEventDispatcherTest.php

示例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'));
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:16,代码来源:EventDispatcherTest.php

示例10: hasListeners

 public function hasListeners($eventName = null)
 {
     return $this->eventDispatcher->hasListeners($eventName);
 }
开发者ID:mpoiriert,项目名称:nucleus,代码行数:4,代码来源:EventDispatcher.php


注:本文中的Symfony\Component\EventDispatcher\EventDispatcher::hasListeners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。