コード例 #1
0
 /**
  * Get a container with collector that contains passed widgets
  *
  * @param $widgets
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 protected function getContainerWithCollectorMock($widgets)
 {
     $collector = new TypeCollector();
     foreach ($widgets as $widget) {
         $collector->add($widget);
     }
     $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock();
     $container->method('get')->willReturn($collector);
     return $container;
 }
コード例 #2
0
ファイル: TypeCollectorTest.php プロジェクト: enhavo/enhavo
 function testTypeCollector()
 {
     $collector = new TypeCollector($this->getContainerMock());
     $collector->add('alias1', 'id1');
     $collector->add('alias2', 'id2');
     $type1 = $collector->getType('alias1');
     $type2 = $collector->getType('alias2');
     static::assertInstanceOf(TypeInterface::class, $type1);
     static::assertInstanceOf(TypeInterface::class, $type2);
     $this->assertEquals('alias1', $type1->getType('id1'));
     $this->assertEquals('alias2', $type2->getType('id2'));
 }
コード例 #3
0
ファイル: SitemapGenerator.php プロジェクト: enhavo/enhavo
 protected function getUrls()
 {
     /** @var SitemapUrl[] $urls */
     $urls = [];
     foreach ($this->configuration as $name => $configuration) {
         if (!isset($configuration['type'])) {
             throw new \InvalidArgumentException(sprintf('SitemapCollector "%s" has not type', $name));
         }
         $type = $configuration['type'];
         /** @var CollectorInterface $collector */
         $collector = $this->collector->getType($type);
         $collector = clone $collector;
         $collector->setOptions($configuration);
         $urls = array_merge($urls, $collector->getUrls());
     }
     return $urls;
 }
コード例 #4
0
ファイル: ListMenuBuilder.php プロジェクト: enhavo/enhavo
 public function createMenu(array $options)
 {
     parent::createMenu($options);
     $name = 'list';
     if (isset($options['name'])) {
         $name = $options['name'];
     }
     $menu = $this->getFactory()->createItem($name);
     foreach ($this->menu as $name => $itemOptions) {
         /** @var MenuBuilderInterface $menuBuilder */
         $menuBuilder = $this->menuItemTypeCollector->getType($itemOptions['type']);
         $itemOptions['name'] = $name;
         if ($menuBuilder->isGranted()) {
             $menu->addChild($menuBuilder->createMenu($itemOptions));
         }
     }
     return $menu;
 }
コード例 #5
0
 /**
  * @return ItemConfiguration[]
  */
 public function getItemConfigurations()
 {
     if ($this->itemConfigurations !== null) {
         return $this->itemConfigurations;
     }
     $itemConfigurations = [];
     foreach ($this->items as $name => $item) {
         $type = 'base';
         if (array_key_exists('type', $item)) {
             $type = $item['type'];
         }
         /** @var ConfigurationInterface $configurationType */
         $configurationType = $this->collector->getType($type);
         $itemConfigurations[] = $configurationType->configure($name, $item);
     }
     $this->itemConfigurations = $itemConfigurations;
     return $itemConfigurations;
 }
コード例 #6
0
ファイル: ViewerFactory.php プロジェクト: enhavo/enhavo
 public function create(RequestConfigurationInterface $configuration, MetadataInterface $metadata = null, $newResource = null, Form $form = null, $defaultType = null)
 {
     $viewerType = $configuration->getViewerType() ? $configuration->getViewerType() : $defaultType;
     /** @var ViewerInterface $viewer */
     $viewer = $this->collector->getType($viewerType);
     $viewer = clone $viewer;
     $viewer->setContainer($this->container);
     $viewer->setConfiguration($configuration);
     if ($metadata) {
         $viewer->setMetadata($metadata);
     }
     if ($form) {
         $viewer->setForm($form);
     }
     if ($newResource) {
         $viewer->setResource($newResource);
     }
     $optionAccessor = new OptionAccessor();
     $viewer->configureOptions($optionAccessor);
     $optionAccessor->resolve($configuration->getViewerOptions());
     $viewer->setOptionAccessor($optionAccessor);
     return $viewer;
 }
コード例 #7
0
ファイル: StrategyResolver.php プロジェクト: enhavo/enhavo
 public function resolve($type)
 {
     $name = $this->resolveName($type);
     return $this->strategyTypeCollector->getType($name);
 }
コード例 #8
0
ファイル: SubscriberManager.php プロジェクト: enhavo/enhavo
 /**
  * @return StorageInterface
  * @throws \Enhavo\Bundle\AppBundle\Exception\TypeNotFoundException
  */
 public function getStorageByName($name)
 {
     return $this->storageTypeCollector->getType($name);
 }
コード例 #9
0
ファイル: SubscriberManager.php プロジェクト: enhavo/enhavo
 /**
  * @return StorageInterface
  * @throws \Enhavo\Bundle\AppBundle\Exception\TypeNotFoundException
  */
 public function getStorage()
 {
     return $this->storageTypeCollector->getType($this->storage);
 }
コード例 #10
0
ファイル: TypeCollectorTest.php プロジェクト: npakai/enhavo
 /**
  * @expectedException Enhavo\Bundle\AppBundle\Exception\TypeNotFoundException
  */
 function testGettingNonExistingType()
 {
     $collector = new TypeCollector();
     $collector->add($this->buildTypeMock('type1'));
     $collector->getType('NonExistingType');
 }