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


PHP EventManager::setSharedManager方法代碼示例

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


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

示例1: setUp

 public function setUp()
 {
     // Store original autoloaders
     $this->loaders = spl_autoload_functions();
     if (!is_array($this->loaders)) {
         // spl_autoload_functions does not return empty array when no
         // autoloaders registered...
         $this->loaders = array();
     }
     // Store original include_path
     $this->includePath = get_include_path();
     $autoloader = new ModuleAutoloader(array(dirname(__DIR__) . '/TestAsset'));
     $autoloader->register();
     $this->sharedEvents = new SharedEventManager();
     $this->moduleManager = new ModuleManager(array('ListenerTestModule'));
     $this->moduleManager->getEventManager()->setSharedManager($this->sharedEvents);
     $this->moduleManager->getEventManager()->attach('loadModule.resolve', new ModuleResolverListener(), 1000);
     $this->application = new MockApplication();
     $events = new EventManager(array('Zend\\Mvc\\Application', 'ZendTest\\Module\\TestAsset\\MockApplication', 'application'));
     $events->setSharedManager($this->sharedEvents);
     $this->application->setEventManager($events);
     $this->serviceManager = new ServiceManager();
     $this->serviceManager->setService('ModuleManager', $this->moduleManager);
     $this->application->setServiceManager($this->serviceManager);
 }
開發者ID:haoyanfei,項目名稱:zf2,代碼行數:25,代碼來源:LocatorRegistrationListenerTest.php

示例2: createService

 /**
  * Create an instance of EventManagerProxy
  * 
  * @param ServiceLocatorInterface $serviceLocator
  * 
  * @return EventManagerProxy
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $proxy = new EventManagerProxy();
     $em = new EventManager();
     $em->setSharedManager($serviceLocator->get('SharedEventManager'));
     $proxy->setEventManager($em);
     return $proxy;
 }
開發者ID:malocher,項目名稱:zf2-event-store-module,代碼行數:15,代碼來源:EventManagerProxyFactory.php

示例3: testAttach

 public function testAttach()
 {
     $sharedEvents = new SharedEventManager();
     $events = new EventManager();
     $events->setSharedManager($sharedEvents);
     $listener = new AccessListener();
     $listener->attach($events);
     $this->assertCount(1, $sharedEvents->getListeners('SporkTools', MvcEvent::EVENT_DISPATCH));
 }
開發者ID:sporkcode,項目名稱:sporktools,代碼行數:9,代碼來源:AccessListenerTest.php

示例4: setUp

 public function setUp()
 {
     $this->module = new Module();
     $this->app = $this->getMockBuilder('Zend\\Mvc\\Application')->disableOriginalConstructor()->getMock();
     $sm = new ServiceManager(new Config(['services' => ['translator' => Translator::factory(['locale' => 'id_ID'])]]));
     $this->app->expects($this->any())->method('getServiceManager')->willReturn($sm);
     $em = new EventManager();
     $em->setSharedManager(new SharedEventManager());
     $this->app->expects($this->any())->method('getEventManager')->willReturn($em);
 }
開發者ID:jkhaled,項目名稱:LearnZF2,代碼行數:10,代碼來源:ModuleTest.php

示例5: marshalEventManager

 public function marshalEventManager()
 {
     $r = new ReflectionClass(EventManager::class);
     if ($r->hasMethod('setSharedManager')) {
         $eventManager = new EventManager();
         $eventManager->setSharedManager(new SharedEventManager());
         return $eventManager;
     }
     return new EventManager(new SharedEventManager());
 }
開發者ID:zfcampus,項目名稱:zf-api-problem,代碼行數:10,代碼來源:ModuleTest.php

示例6: testCanAttachListeners

 public function testCanAttachListeners()
 {
     $mockListener = $this->getMock('EventLogger\\Log\\Listener\\LogListener');
     $serviceManager = new ServiceManager();
     $serviceManager->setService('EventLogger\\Log\\Listener\\AppListener', $mockListener);
     $serviceManager->setService('EventLogger\\Log\\Listener\\DispatchErrorListener', $mockListener);
     $eventManager = new EventManager();
     $eventManager->setSharedManager(new SharedEventManager());
     $listenerAggregate = new ListenerAggregate($serviceManager);
     $listenerAggregate->attach($eventManager);
 }
開發者ID:cyawman,項目名稱:event-logger,代碼行數:11,代碼來源:ListenerAggregateTest.php

示例7: setUp

 public function setUp()
 {
     $this->module = new Module();
     $app = $this->prophesize('Zend\\Mvc\\Application');
     $sm = new ServiceManager(new Config(['services' => ['translator' => Translator::factory(['locale' => 'id_ID'])]]));
     $app->getServiceManager()->willReturn($sm);
     $em = new EventManager();
     $em->setSharedManager(new SharedEventManager());
     $app->getEventManager()->willReturn($em);
     $this->app = $app->reveal();
 }
開發者ID:sitrunlab,項目名稱:learnzf2,代碼行數:11,代碼來源:ModuleTest.php

示例8: createService

 /**
  * Create an EventManager instance
  *
  * Creates a new EventManager instance, seeding it with a shared instance
  * of SharedEventManager.
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return EventManager
  * @throws ServiceNotFoundException
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if ($serviceLocator instanceof AbstractPluginManager) {
         $serviceLocator = $serviceLocator->getServiceLocator();
     }
     /** @var SharedEventManagerInterface $sharedEventManager */
     $sharedEventManager = $serviceLocator->get('SharedEventManager');
     $em = new EventManager();
     $em->setSharedManager($sharedEventManager);
     return $em;
 }
開發者ID:abacaphiliac,項目名稱:zend-eventmanager-pluginmanager,代碼行數:21,代碼來源:EventManagerFactory.php

示例9: createEventManager

 /**
  * Create and return an EventManager composing the shared event manager instance.
  *
  * @return EventManager
  */
 private function createEventManager()
 {
     $r = new \ReflectionClass(EventManager::class);
     if ($r->hasMethod('setSharedManager')) {
         // zend-eventmanager v2 initialization
         $eventManager = new EventManager();
         $eventManager->setSharedManager($this->sharedEventManager);
         return $eventManager;
     }
     // zend-eventmanager v3 initialization
     return new EventManager($this->sharedEventManager);
 }
開發者ID:zfcampus,項目名稱:zf-apigility-doctrine,代碼行數:17,代碼來源:DoctrineRestServiceModelFactory.php

示例10: __invoke

 /**
  * Create an EventManager instance
  *
  * Creates a new EventManager instance, seeding it with a shared instance
  * of SharedEventManager.
  *
  * @param  ContainerInterface $container
  * @param  string $name
  * @param  null|array $options
  * @return EventManager
  */
 public function __invoke(ContainerInterface $container, $name, array $options = null)
 {
     if ($this->acceptsSharedManagerToConstructor()) {
         // zend-eventmanager v3
         return new EventManager($container->has('SharedEventManager') ? $container->get('SharedEventManager') : null);
     }
     // zend-eventmanager v2
     $events = new EventManager();
     if ($container->has('SharedEventManager')) {
         $events->setSharedManager($container->get('SharedEventManager'));
     }
     return $events;
 }
開發者ID:zendframework,項目名稱:zend-mvc,代碼行數:24,代碼來源:EventManagerFactory.php

示例11: createEventManager

 /**
  * @param ContainerInterface $container
  *
  * @return EventManager
  */
 protected function createEventManager(ContainerInterface $container)
 {
     if ($this->acceptsSharedManagerToConstructor()) {
         // zend-eventmanager v3
         return new EventManager($container->has('SharedEventManager') ? $container->get('SharedEventManager') : null);
     }
     // zend-eventmanager v2
     $events = new EventManager();
     if ($container->has('SharedEventManager')) {
         $events->setSharedManager($container->get('SharedEventManager'));
     }
     return $events;
 }
開發者ID:thomasvargiu,項目名稱:pami-module,代碼行數:18,代碼來源:ClientFactory.php

示例12: setUp

 protected function setUp()
 {
     $module = new Module();
     $events = new EventManager();
     $sharedEvents = new SharedEventManager();
     $events->setSharedManager($sharedEvents);
     $plugins = new ControllerPluginManager();
     $this->serviceManager = new ServiceManager();
     $this->serviceManager->setService('Zend\\ServiceManager\\ServiceLocatorInterface', $this->serviceManager);
     $this->serviceManager->setService('EventManager', $events);
     $this->serviceManager->setService('SharedEventManager', $sharedEvents);
     $this->serviceManager->setService('ControllerPluginManager', $plugins);
     $this->controllerManager = new ControllerManager(new Config($module->getControllerConfig()));
     $this->controllerManager->setServiceLocator($this->serviceManager);
     $this->controllerManager->addPeeringServiceManager($this->serviceManager);
 }
開發者ID:t4web,項目名稱:Modules,代碼行數:16,代碼來源:ListControllerTest.php

示例13: testEventListenerIsAttached

 public function testEventListenerIsAttached()
 {
     $module = new Module();
     $mvcEvent = $this->getMock('Zend\\EventManager\\EventInterface');
     $application = $this->getMock('Zend\\Mvc\\Application', [], [], '', false);
     $eventManager = new EventManager();
     $eventManager->setSharedManager(new SharedEventManager());
     $serviceManager = new ServiceManager();
     $mvcEvent->expects($this->once())->method('getParam')->with('application')->will($this->returnValue($application));
     $application->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager));
     $application->expects($this->once())->method('getServiceManager')->will($this->returnValue($serviceManager));
     $eventManager->addIdentifiers(['ZfcUser\\Service\\User']);
     $event = new Event();
     $event->setName('register.post');
     $userRegistrationService = $this->getMock('HtUserRegistration\\Service\\UserRegistrationServiceInterface');
     $serviceManager->setService('HtUserRegistration\\UserRegistrationService', $userRegistrationService);
     $userRegistrationService->expects($this->once())->method('onUserRegistration')->with($event);
     $module->onBootstrap($mvcEvent);
     $eventManager->trigger($event);
 }
開發者ID:Ellipizle,項目名稱:HtUserRegistration,代碼行數:20,代碼來源:ModuleTest.php

示例14: setUp

 public function setUp()
 {
     $this->loaders = spl_autoload_functions();
     if (!is_array($this->loaders)) {
         // spl_autoload_functions does not return empty array when no
         // autoloaders registered...
         $this->loaders = array();
     }
     // Store original include_path
     $this->includePath = get_include_path();
     $autoloader = new ModuleAutoloader(array(dirname(__DIR__) . '/TestAsset'));
     $autoloader->register();
     $sharedEvents = new SharedEventManager();
     $this->moduleManager = new ModuleManager(array());
     $this->moduleManager->getEventManager()->setSharedManager($sharedEvents);
     $this->moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULE_RESOLVE, new ModuleResolverListener(), 1000);
     $this->moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULE, new OnBootstrapListener(), 1000);
     $this->application = new MockApplication();
     $events = new EventManager(array('Zend\\Mvc\\Application', 'ZendTest\\Module\\TestAsset\\MockApplication', 'application'));
     $events->setSharedManager($sharedEvents);
     $this->application->setEventManager($events);
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:22,代碼來源:OnBootstrapListenerTest.php

示例15: createEventManager

 /**
  * Create and return an event manager instance.
  *
  * Ensures that the returned event manager has a shared manager
  * composed.
  *
  * @return EventManager
  */
 private function createEventManager()
 {
     $r = new ReflectionClass(EventManager::class);
     if ($r->hasMethod('setSharedManager')) {
         $events = new EventManager();
         $events->setSharedManager(new SharedEventManager());
     } else {
         $events = new EventManager(new SharedEventManager());
     }
     $this->setEventManager($events);
     return $events;
 }
開發者ID:froschdesign,項目名稱:zend-view,代碼行數:20,代碼來源:AbstractHelper.php


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