Applied CS fixer

This commit is contained in:
Kevin Frantz
2018-10-29 19:01:00 +01:00
parent 91c41105c7
commit 6bc95f9729
46 changed files with 270 additions and 281 deletions

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -7,9 +8,7 @@ use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Translation\TranslatorInterface;
/**
*
* @author kevinfrantz
*
*/
abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
{
@@ -17,52 +16,53 @@ abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
* @var TranslatorInterface
*/
private $translator;
const FORMAT_TYPES = [
'html',
'json',
'xml'
'xml',
];
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
protected function generateShowDropdown(ItemInterface $menu, Event $event,string $route): void
protected function generateShowDropdown(ItemInterface $menu, Event $event, string $route): void
{
$dropdown = $menu->addChild($this->trans('show'), [
'attributes' => [
'icon' => 'fas fa-eye',
'dropdown' => 'true'
]
'dropdown' => 'true',
],
]);
foreach (self::FORMAT_TYPES as $format) {
$dropdown->addChild($format, [
'route' => $route,
'routeParameters' => [
'id' => $this->getRequestId($event),
'_format' => $format
'_format' => $format,
],
'attributes' => [
'icon' => 'fas fa-sign-out-alt',
'divider_append' => true
]
'divider_append' => true,
],
]);
}
$dropdown->addChild($this->trans('standard'), [
'route' => $route,
'routeParameters' => [
'id' => $this->getRequestId($event)
'id' => $this->getRequestId($event),
],
'attributes' => [
'icon' => 'fas fa-sign-out-alt'
]
'icon' => 'fas fa-sign-out-alt',
],
]);
}
protected function trans(string $id, array $parameter=[]):string{
return $this->translator->trans($id,$parameter);
protected function trans(string $id, array $parameter = []): string
{
return $this->translator->trans($id, $parameter);
}
protected function getRequestId(Event $event): int
@@ -70,4 +70,3 @@ abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
return $event->getRequest()->getCurrentRequest()->attributes->get('id');
}
}

View File

@@ -1,20 +1,19 @@
<?php
namespace App\Subscriber;
use App\DBAL\Types\MenuEventType;
use App\Event\Menu\MenuEvent;
/**
*
* @author kevinfrantz
*
*/
class NodeMenuSubscriber extends AbstractEntityMenuSubscriber
{
public function onNodeMenuConfigure(MenuEvent $event): void
{
$menu = $event->getItem();
$this->generateShowDropdown($menu, $event,'app_source_show');
$this->generateShowDropdown($menu, $event, 'app_source_show');
$menu->addChild($this->trans('law'), [
'route' => 'app_node_law',
'routeParameters' => [
@@ -43,12 +42,11 @@ class NodeMenuSubscriber extends AbstractEntityMenuSubscriber
],
]);
}
public static function getSubscribedEvents()
{
return [
MenuEventType::NODE => 'onNodeMenuConfigure'
MenuEventType::NODE => 'onNodeMenuConfigure',
];
}
}

View File

@@ -19,7 +19,7 @@ class SourceMenuSubscriber extends AbstractEntityMenuSubscriber
'icon' => 'fas fa-edit',
],
]);
$this->generateShowDropdown($menu, $event,'app_source_show');
$this->generateShowDropdown($menu, $event, 'app_source_show');
$menu->addChild($this->trans('node'), [
'route' => 'app_source_node',
'routeParameters' => [

View File

@@ -90,7 +90,7 @@ class UserMenuSubscriber implements EventSubscriberInterface
public static function getSubscribedEvents(): array
{
return [
MenuEventType::USER=> 'onUserMenuConfigure',
MenuEventType::USER => 'onUserMenuConfigure',
];
}
}