diff --git a/DependencyInjection/ChillDocStoreExtension.php b/DependencyInjection/ChillDocStoreExtension.php index 86da6ac79..aae7c1a16 100644 --- a/DependencyInjection/ChillDocStoreExtension.php +++ b/DependencyInjection/ChillDocStoreExtension.php @@ -28,6 +28,7 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf $loader->load('services.yml'); $loader->load('services/media.yml'); $loader->load('services/controller.yml'); + $loader->load('services/menu.yml'); } diff --git a/Menu/MenuBuilder.php b/Menu/MenuBuilder.php new file mode 100644 index 000000000..03a8b7038 --- /dev/null +++ b/Menu/MenuBuilder.php @@ -0,0 +1,87 @@ + + */ +class MenuBuilder implements LocalMenuBuilderInterface +{ + /** + * + * @var TokenStorageInterface + */ + protected $tokenStorage; + + /** + * + * @var AuthorizationHelper + */ + protected $authorizationHelper; + + /** + * + * @var TranslatorInterface + */ + protected $translator; + + public function __construct( + TokenStorageInterface $tokenStorage, + AuthorizationHelper $authorizationHelper, + TranslatorInterface $translator + ){ + $this->tokenStorage = $tokenStorage; + $this->authorizationHelper = $authorizationHelper; + $this->translator = $translator; + } + + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + switch($menuId) { + case 'person': + $this->buildMenuPerson($menu, $parameters); + break; + default: + throw new \LogicException("this menuid $menuId is not implemented"); + } + } + + protected function buildMenuPerson(MenuItem $menu, array $parameters) + { + /* @var $person \Chill\PersonBundle\Entity\Person */ + $person = $parameters['person']; + $user = $this->tokenStorage->getToken()->getUser(); + + if ($this->authorizationHelper->userHasAccess($user, + $person->getCenter(), PersonDocumentVoter::SEE)) { + + $menu->addChild($this->translator->trans('Documents'), [ + 'route' => 'person_document_index', + 'routeParameters' => [ + 'person' => $person->getId() + ] + ]) + ->setExtras([ + 'order'=> 350 + ]); + } + + } + + public static function getMenuIds(): array + { + return [ 'person' ]; + } +} diff --git a/Resources/config/services/menu.yml b/Resources/config/services/menu.yml new file mode 100644 index 000000000..069cd64d4 --- /dev/null +++ b/Resources/config/services/menu.yml @@ -0,0 +1,8 @@ +services: + Chill\DocStoreBundle\Menu\MenuBuilder: + arguments: + $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: 'chill.menu_builder' } diff --git a/Resources/translation/messages.yml b/Resources/translation/messages.yml deleted file mode 100644 index 68a2b380b..000000000 --- a/Resources/translation/messages.yml +++ /dev/null @@ -1,2 +0,0 @@ -## YAML Template. ---- diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml new file mode 100644 index 000000000..b73cef05f --- /dev/null +++ b/Resources/translations/messages.fr.yml @@ -0,0 +1,13 @@ +Document: Document +Documents for %name%: Documents de %name% +Preparing: En préparation +Ready to show: Prêt à être visualisé +Download: Télécharger +Create new document: Créer un nouveau document +New document for %name%: Nouveau document pour %name% +Editing document for %name%: Modification d'un document pour %name% +Edit Document: Modification d'un document +Existing document: Document existant +The document is successfully updated: Le document est mis à jour + + diff --git a/Resources/translation/validators.fr.yml b/Resources/translations/validators.fr.yml similarity index 100% rename from Resources/translation/validators.fr.yml rename to Resources/translations/validators.fr.yml diff --git a/Resources/views/Macro/macro.html.twig b/Resources/views/Macro/macro.html.twig index 36b2793e3..a9f990dca 100644 --- a/Resources/views/Macro/macro.html.twig +++ b/Resources/views/Macro/macro.html.twig @@ -1,3 +1,3 @@ {% macro download_button(storedObject, filename = null) %} - {{ 'Download'|trans }} + {{ 'Download'|trans }} {% endmacro %} diff --git a/Resources/views/PersonDocument/index.html.twig b/Resources/views/PersonDocument/index.html.twig index 8c73cc739..806ef67d5 100644 --- a/Resources/views/PersonDocument/index.html.twig +++ b/Resources/views/PersonDocument/index.html.twig @@ -28,7 +28,7 @@ {% endblock %} {% block personcontent %} -
{{ 'Title' | trans }} | -{{ document.title }} | -
---|---|
{{ 'Description' | trans }} | -{{ document.description }} | -
{{ 'Content' | trans }} | -{{ document.content }} | -
{{ 'Center' | trans}} | -{{ document.center }} | -
{{ 'Scope' | trans }} | -{{ document.scope.name | localize_translatable_string }} | -
{{ 'Last modificiation by' | trans }} | -{{ document.user }} | -
{{ 'Last update' | trans }} | -{{ document.date ? document.date|date('Y-m-d H:i:s') : '' }} | -
+ {{ document.description }} ++ {% endif %} +