當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。