当前位置: 首页>>代码示例>>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;未经允许,请勿转载。