Implemented user source to menu

This commit is contained in:
Kevin Frantz
2019-03-31 18:17:11 +02:00
parent 1aa5d35169
commit a11296df5b
2 changed files with 23 additions and 4 deletions

View File

@@ -109,17 +109,28 @@ class UserMenuSubscriber extends AbstractEntityMenuSubscriber implements EventSu
$slug = $fixtureSource::getSlug();
$name = $fixtureSource->getName();
$icon = $fixtureSource::getIcon();
$item->addChild($this->trans($name), [
$item->addChild($this->trans($name), $this->getSourceItemConfigurationArray($slug, $icon));
}
/**
* @param string $identity
* @param string $icon
*
* @return []
*/
private function getSourceItemConfigurationArray(string $identity, string $icon)
{
return [
'route' => self::LAYER_GET_ROUTE,
'routeParameters' => [
LayerController::IDENTITY_PARAMETER_KEY => $slug,
LayerController::IDENTITY_PARAMETER_KEY => $identity,
LayerController::FORMAT_PARAMETER_KEY => RESTResponseType::HTML,
LayerController::LAYER_PARAMETER_KEY => LayerType::SOURCE,
],
'attributes' => [
'icon' => $icon,
],
]);
];
}
/**
@@ -177,6 +188,10 @@ class UserMenuSubscriber extends AbstractEntityMenuSubscriber implements EventSu
'divider_append' => true,
],
]);
$userSource = $this->getToken()->getUser()->getSource();
$identity = $userSource->getId();
$icon = 'fas fa-user';
$dropdown->addChild($this->trans('user source'), $this->getSourceItemConfigurationArray($identity, $icon));
} else {
$dropdown->addChild($this->trans('login'), [
'route' => 'fos_user_security_login',