Пример #1
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $definitions = $this->widgetDefinitionsRegistry->getWidgetDefinitions();
     if ($definitions->isEmpty()) {
         return;
     }
     $definitions = $definitions->toArray();
     foreach ($definitions as &$definition) {
         if (!empty($definition['icon'])) {
             $definition['icon'] = $this->assetHelper->getUrl($definition['icon']);
         }
     }
     $this->widgetDefinitionsRegistry->setWidgetDefinitions($definitions);
 }
 /**
  * @dataProvider configurationDataProvider
  * @param array $definitions
  * @param string $placement
  * @param array $expected
  */
 public function testGetWidgetDefinitionsByPlacement(array $definitions, $placement, array $expected)
 {
     $registry = new WidgetDefinitionRegistry($definitions);
     $actual = $registry->getWidgetDefinitionsByPlacement($placement);
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $actual);
     $this->assertEquals($expected, $actual->toArray());
     $additionalDefinition = ['last' => ['icon' => 'icon.png']];
     $registry->setWidgetDefinitions($additionalDefinition);
     $this->assertEquals(array_merge($definitions, $additionalDefinition), $registry->getWidgetDefinitions()->toArray());
 }