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


PHP EventManager::attachAggregate方法代码示例

本文整理汇总了PHP中Zend\EventManager\EventManager::attachAggregate方法的典型用法代码示例。如果您正苦于以下问题:PHP EventManager::attachAggregate方法的具体用法?PHP EventManager::attachAggregate怎么用?PHP EventManager::attachAggregate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\EventManager\EventManager的用法示例。


在下文中一共展示了EventManager::attachAggregate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCanDetachListenersFromEventManager

 public function testCanDetachListenersFromEventManager()
 {
     $events = new EventManager();
     $events->attachAggregate($this->strategy);
     $this->assertEquals(1, count($events->getListeners(MvcEvent::EVENT_RENDER)));
     $events->detachAggregate($this->strategy);
     $this->assertEquals(0, count($events->getListeners(MvcEvent::EVENT_RENDER)));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:8,代码来源:DefaultRenderingStrategyTest.php

示例2: testDetachesListeners

 public function testDetachesListeners()
 {
     $events = new EventManager();
     $events->attachAggregate($this->listener);
     $listeners = $events->getListeners('dispatch');
     $this->assertEquals(1, count($listeners));
     $events->detachAggregate($this->listener);
     $listeners = $events->getListeners('dispatch');
     $this->assertEquals(0, count($listeners));
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:10,代码来源:CreateViewModelFromArrayListenerTest.php

示例3: testDetachesListeners

 public function testDetachesListeners()
 {
     $events = new EventManager();
     $events->attachAggregate($this->listener);
     $listeners = $events->getListeners(MvcEvent::EVENT_DISPATCH);
     $this->assertEquals(2, count($listeners));
     $events->detachAggregate($this->listener);
     $listeners = $events->getListeners(MvcEvent::EVENT_DISPATCH);
     $this->assertEquals(0, count($listeners));
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:10,代码来源:CreateViewModelListenerTest.php

示例4: register

 /**
  * @SWG\Property(name="station_id",type="integer",description="Unique identifier of the gas station")
  * @SWG\Property(name="name",type="string",description="Name of the gas station")
  * @SWG\Property(name="social_reason",type="string",description="Official name of the gas station")
  * @SWG\Property(name="address_line_1",type="string",description="Street name and number of the gas station")
  * @SWG\Property(name="address_line_2",type="string",description="Neighborhood name of the gas station")
  * @SWG\Property(name="location",type="string",description="State and city name where the gas station is located")
  * @SWG\Property(name="latitude",type="double",description="Latitude coordinate")
  * @SWG\Property(name="longitude",type="double",description="Longitude coordinate")
  * @SWG\Property(name="created_at",type="string",format="date-format",description="Registration date of the gas station")
  * @SWG\Property(name="last_updated_at",type="string",format="date-format",description="Most recent date in which the gas station was edited")
  */
 public function register(Slim $app)
 {
     $app->container->singleton('station', function () use($app) {
         return new Model($app->stationTable, $app->stationValidator, $app->paginatorFactory);
     });
     $app->container->singleton('stationFormatter', function () use($app) {
         return new ResourceFormatter($app->urlHelper, 'station', 'station_id');
     });
     $app->container->singleton('stationsFormatter', function () use($app) {
         return new CollectionFormatter($app->urlHelper, 'stations', $app->stationFormatter);
     });
     $app->container->singleton('stationEvents', function () use($app) {
         $eventManager = new EventManager();
         $specification = new ChainedSpecification();
         $specification->addSpecification(new PaginationSpecification($app->config('defaultPageSize')));
         $specification->addSpecification(new GeolocationSpecification());
         $eventManager->attach('postFindAll', new QuerySpecificationListener($specification));
         $eventManager->attachAggregate(new HasTimestampListener());
         $eventManager->attachAggregate(new CacheListener($app->cache, $app->request()->getPathInfo()));
         return $eventManager;
     });
     $app->container->singleton('stationTable', function () use($app) {
         $stationTable = new StationTable('stations', $app->connection);
         $factory = new TableProxyFactory($app->proxiesConfiguration, $app->stationEvents);
         $stationTable = $factory->createProxy($stationTable);
         $factory->addEventManagement($stationTable);
         return $stationTable;
     });
     $app->container->singleton('stationValidator', function () use($app) {
         return new ValitronValidator(require 'config/validations/stations.config.php');
     });
     $app->container->singleton('stationController', function () use($app) {
         $app->controller->setModel($app->station);
         $app->controllerEvents->attach('postDispatch', new FormatResourceListener($app->stationFormatter));
         return $app->controller;
     });
     $app->container->singleton('stationsController', function () use($app) {
         $app->controller->setModel($app->station);
         $app->controllerEvents->attach('postDispatch', new FormatResourceListener($app->stationsFormatter));
         return $app->controller;
     });
 }
开发者ID:comphppuebla,项目名称:echale-gas-api,代码行数:54,代码来源:StationContainer.php

示例5: testDetachesListeners

 public function testDetachesListeners()
 {
     $events = new EventManager();
     $events->attachAggregate($this->strategy);
     $listeners = $events->getListeners('renderer');
     $this->assertEquals(1, count($listeners));
     $listeners = $events->getListeners('response');
     $this->assertEquals(1, count($listeners));
     $events->detachAggregate($this->strategy);
     $listeners = $events->getListeners('renderer');
     $this->assertEquals(0, count($listeners));
     $listeners = $events->getListeners('response');
     $this->assertEquals(0, count($listeners));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:14,代码来源:PhpRendererStrategyTest.php

示例6: testListenerAttachesDispatchEventAtExpectedPriority

 public function testListenerAttachesDispatchEventAtExpectedPriority()
 {
     $events = new EventManager();
     $events->attachAggregate($this->listener);
     $listeners = $events->getListeners(MvcEvent::EVENT_DISPATCH);
     $expectedCallback = [$this->listener, 'injectActionHandles'];
     $expectedPriority = 1000;
     $found = false;
     foreach ($listeners as $listener) {
         $callback = $listener->getCallback();
         if ($callback === $expectedCallback) {
             if ($listener->getMetadatum('priority') == $expectedPriority) {
                 $found = true;
                 break;
             }
         }
     }
     $this->assertTrue($found, 'Listener not found');
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:19,代码来源:ActionHandlesListenerTest.php

示例7: attach

 /**
  * 
  * @param ListenerAggregateInterface $listener
  */
 public function attach(ListenerAggregateInterface $listener)
 {
     $this->eventManager->attachAggregate($listener);
 }
开发者ID:Okeanrst,项目名称:zf-annotations,代码行数:8,代码来源:ClassParser.php

示例8: testPrepareExceptionRendersPreviousMessages

 public function testPrepareExceptionRendersPreviousMessages()
 {
     $events = new EventManager();
     $events->attachAggregate($this->strategy);
     $messages = array('message foo', 'message bar', 'deepest message');
     $exception = null;
     $i = 0;
     do {
         $exception = new \Exception($messages[$i], null, $exception);
         $i++;
     } while ($i < count($messages));
     $event = new MvcEvent(MvcEvent::EVENT_DISPATCH_ERROR, null, array('exception' => $exception));
     $event->setError('user-defined-error');
     $events->trigger($event, null, array('exception' => $exception));
     //$this->strategy->prepareExceptionViewModel($event);
     foreach ($messages as $message) {
         $this->assertContains($message, $event->getResult()->getResult(), sprintf('Not all errors are rendered'));
     }
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:19,代码来源:ExceptionStrategyTest.php


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