diff --git a/readme.md b/readme.md index 439cb41dd4849aff99fddd5bcd6e2979e6aacabc..e90cec395f0ab36e667f1e1bf7f7c5a7c33d3060 100644 --- a/readme.md +++ b/readme.md @@ -77,39 +77,26 @@ Privilèges associés au module **N.B.** Le script permettant de créer les tables est fourni dans le fichier [privilege/SQL/002_privileges.sql] -1 - Macro - -```php -const DOCUMENTMACRO_INDEX = 'documentmacro-documentmacro_index'; -const DOCUMENTMACRO_AJOUTER = 'documentmacro-documentmacro_ajouter'; -const DOCUMENTMACRO_MODIFIER = 'documentmacro-documentmacro_modifier'; -const DOCUMENTMACRO_SUPPRIMER = 'documentmacro-documentmacro_supprimer'; -``` - -2 - Template - ```php -const DOCUMENTTEMPLATE_INDEX = 'documenttemplate-documenttemplate_index'; -const DOCUMENTTEMPLATE_AFFICHER = 'documenttemplate-documenttemplate_afficher'; -const DOCUMENTTEMPLATE_AJOUTER = 'documenttemplate-documenttemplate_ajouter'; -const DOCUMENTTEMPLATE_MODIFIER = 'documenttemplate-documenttemplate_modifier'; -const DOCUMENTTEMPLATE_SUPPRIMER = 'documenttemplate-documenttemplate_supprimer'; -``` - -3 - Rendu - -```php -const DOCUMENTCONTENU_INDEX = 'documentcontenu-documentcontenu_index'; -const DOCUMENTCONTENU_AFFICHER = 'documentcontenu-documentcontenu_afficher'; -const DOCUMENTCONTENU_SUPPRIMER = 'documentcontenu-documentcontenu_supprimer'; +const PRIVILEGE_VOIR = 'privilege-privilege_voir'; +const PRIVILEGE_AJOUTER = 'privilege-privilege_ajouter'; +const PRIVILEGE_MODIFIER = 'privilege-privilege_modifier'; +const PRIVILEGE_SUPPRIMER = 'privilege-privilege_supprimer'; +const PRIVILEGE_AFFECTER = 'privilege-privilege_affecter'; ``` ***Attention !!!*** Penser à donner les privilèges aux rôles adéquats. Dépendance à **UnicaenUtilisateur** ---------------------------------- -1. Dans **vendor/unicaen/renderer/config/merged/index.config.php**, **vendor/unicaen/renderer/config/merged/macro.config.php**, **vendor/unicaen/renderer/config/merged/rendu.config.php**, **vendor/unicaen/renderer/config/merged/template.config.php** : `UnicaenPrivilege\Guard\PrivilegeController` pour les gardes liées aux actions. - Peut être directement remplacer par l'equivalent fournit par `unicaen/auth`. - -1. Dans **vendor/unicaen/renderer/src/UnicaenRenderer/Provider/Privilege/DocumentcontenuPrivileges.php**, **vendor/unicaen/renderer/src/UnicaenRenderer/Provider/Privilege/DocumentmacroPrivileges.php**, **vendor/unicaen/renderer/src/UnicaenRenderer/Provider/Privilege/DocumenttemplatePrivileges.php** : `UnicaenPrivilege\Provider\Privilege\Privileges` classe mère des privilèges du module. - Peut être directement remplacer par l'equivalent fournit par `unicaen/auth`. \ No newline at end of file +1. Dependance à `Role` et `RoleInterface` : dans la déclaration des privilèges car lié à un tableau de rôle +- AffectationController.php +- AffectationService.php +- AbstractPrivilege.php +- Privilege.php +- PrivilegeInterface.php +- Mapping des privilèges + +1. Dependance à `RoleService` et `RoleServiceAwareTrait` : +- AffectationController.php +- AffectationControllerFactory.php diff --git a/src/UnicaenPrivilege/Controller/CategorieController.php b/src/UnicaenPrivilege/Controller/CategorieController.php index e9234c9217fc27699704f91dbf37dda8510403fb..0cdfc476f8e51cc72a0ff3e309444211d877f08b 100644 --- a/src/UnicaenPrivilege/Controller/CategorieController.php +++ b/src/UnicaenPrivilege/Controller/CategorieController.php @@ -35,7 +35,8 @@ class CategorieController extends AbstractActionController ]); } - public function ajouterAction() { + public function ajouterAction() : ViewModel + { $categorie = new Categorie(); $form = $this->getCategorieForm(); $form->setAttribute('action', $this->url()->fromRoute('unicaen-privilege/categorie/ajouter', [], [], true)); @@ -79,7 +80,8 @@ class CategorieController extends AbstractActionController ]); } - public function modifierAction() { + public function modifierAction() : ViewModel + { $categorie = $this->getCategorieService()->getRequestedCategorie($this); $form = $this->getCategorieForm(); $form->setAttribute('action', $this->url()->fromRoute('unicaen-privilege/categorie/modifier', ['categorie' => $categorie->getId()], [], true)); @@ -106,7 +108,7 @@ class CategorieController extends AbstractActionController return $vm; } - public function supprimerAction() { + public function supprimerAction() : ViewModel { $categorie = $this->getCategorieService()->getRequestedCategorie($this); /** @var Request $request */ diff --git a/src/UnicaenPrivilege/Controller/CategorieControllerFactory.php b/src/UnicaenPrivilege/Controller/CategorieControllerFactory.php index ff855d70e60f6fc04cb2c2c98cea767eed40f8b5..49cf867550a2524f69624c9e23e7b92a625e1744 100644 --- a/src/UnicaenPrivilege/Controller/CategorieControllerFactory.php +++ b/src/UnicaenPrivilege/Controller/CategorieControllerFactory.php @@ -8,7 +8,7 @@ use UnicaenPrivilege\Service\Categorie\CategorieService; class CategorieControllerFactory { - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : CategorieController { /** * @var CategorieService $categorieService diff --git a/src/UnicaenPrivilege/Controller/ConfigurationController.php b/src/UnicaenPrivilege/Controller/ConfigurationController.php deleted file mode 100644 index 26592e23705d256a79d423c972a408ed3afcf41d..0000000000000000000000000000000000000000 --- a/src/UnicaenPrivilege/Controller/ConfigurationController.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -namespace UnicaenPrivilege\Controller; - -use UnicaenPrivilege\Entity\Db\Categorie; -use UnicaenPrivilege\Entity\Db\Privilege; -use UnicaenPrivilege\Form\Categorie\CategorieFormAwareTrait; -use UnicaenPrivilege\Form\Privilege\PrivilegeFormAwareTrait; -use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; -use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait; -use Zend\Http\Request; -use Zend\Mvc\Controller\AbstractActionController; -use Zend\View\Model\ViewModel; - -class ConfigurationController extends AbstractActionController { - use CategorieServiceAwareTrait; - use PrivilegeServiceAwareTrait; - use CategorieFormAwareTrait; - use PrivilegeFormAwareTrait; - - public function indexConfigurationCategorieAction() { - /** - * @var string[] $namespaces - * @var string $namespaces - */ - $namespaces = $this->getCategorieService()->listerNamespaces(); - $namespace = $this->params()->fromQuery('namespace'); - - /** @var Categorie[] $categories */ - $categories = $this->getCategorieService()->getCategories('ordre'); - $namespaceC = ($namespace === "Laissé vide !")?"":$namespace; - if ($namespace !== null AND $namespace !== "") $categories = array_filter($categories, function (Categorie $a) use ($namespaceC) { return $a->getNamespace() == $namespaceC; }); - - return new ViewModel([ - 'namespaces' => $namespaces, - 'namespace' => $namespace, - 'categories' => $categories, - ]); - } - - - - -} \ No newline at end of file diff --git a/src/UnicaenPrivilege/Controller/ConfigurationControllerFactory.php b/src/UnicaenPrivilege/Controller/ConfigurationControllerFactory.php deleted file mode 100644 index 6f87ae5ee36f2e7a71de7e5317f8a1b9eeb25508..0000000000000000000000000000000000000000 --- a/src/UnicaenPrivilege/Controller/ConfigurationControllerFactory.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -namespace UnicaenPrivilege\Controller; - -use Interop\Container\ContainerInterface; -use UnicaenPrivilege\Form\Categorie\CategorieForm; -use UnicaenPrivilege\Form\Privilege\PrivilegeForm; -use UnicaenPrivilege\Service\Categorie\CategorieService; -use UnicaenPrivilege\Service\Privilege\PrivilegeService; - -class ConfigurationControllerFactory { - - public function __invoke(ContainerInterface $container) - { - /** - * @var CategorieService $categorieService - * @var PrivilegeService $privilegeService - */ - $categorieService = $container->get(CategorieService::class); - $privilegeService = $container->get(PrivilegeService::class); - - /** @var CategorieForm $categoriePrivilegeForm */ - $categoriePrivilegeForm = $container->get('FormElementManager')->get(CategorieForm::class); - $privilegeForm = $container->get('FormElementManager')->get(PrivilegeForm::class); - - /** @var ConfigurationController $controller */ - $controller = new ConfigurationController(); - $controller->setCategorieService($categorieService); - $controller->setPrivilegeService($privilegeService); - $controller->setCategorieForm($categoriePrivilegeForm); - $controller->setPrivilegeForm($privilegeForm); - return $controller; - } -} \ No newline at end of file diff --git a/src/UnicaenPrivilege/Controller/PrivilegeController.php b/src/UnicaenPrivilege/Controller/PrivilegeController.php index 24d6e4b23df77f3e313b30995b321df91950b602..14ebee57dcd9b8f7e55e5be02470167bc301cc61 100644 --- a/src/UnicaenPrivilege/Controller/PrivilegeController.php +++ b/src/UnicaenPrivilege/Controller/PrivilegeController.php @@ -15,7 +15,7 @@ class PrivilegeController extends AbstractActionController { use PrivilegeServiceAwareTrait; use PrivilegeFormAwareTrait; - public function ajouterAction() + public function ajouterAction() : ViewModel { $categorie = $this->getCategorieService()->getRequestedCategorie($this); $privilege = new Privilege(); @@ -44,7 +44,8 @@ class PrivilegeController extends AbstractActionController { return $vm; } - public function modifierAction() { + public function modifierAction() : ViewModel + { $privilege = $this->getPrivilegeService()->getRequestedPrivilege($this); $form = $this->getPrivilegeForm(); $form->setAttribute('action', $this->url()->fromRoute('unicaen-privilege/privilege/modifier', ['privilege' => $privilege->getId()], [], true)); @@ -72,7 +73,8 @@ class PrivilegeController extends AbstractActionController { return $vm; } - public function supprimerAction() { + public function supprimerAction() : ViewModel + { $privilege = $this->getPrivilegeService()->getRequestedPrivilege($this); /** @var Request $request */ diff --git a/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php b/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php index c29f2194c3588484f85303420b2c7429e143e0bb..cd75d8b51f528f06f6f6fcc498f19f000c5d1c57 100644 --- a/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php +++ b/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php @@ -53,7 +53,7 @@ interface PrivilegeInterface /** - * @param Categorie $categorie + * @param Categorie|null $categorie * @return self */ public function setCategorie(?Categorie $categorie = null) : PrivilegeInterface; diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieFormAwareTrait.php b/src/UnicaenPrivilege/Form/Categorie/CategorieFormAwareTrait.php index e65c98a70daf4b14b4a29d954c4e55589ac74538..04c13a7522610260bf1f4d0beb521ad1a2408dbe 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieFormAwareTrait.php +++ b/src/UnicaenPrivilege/Form/Categorie/CategorieFormAwareTrait.php @@ -10,7 +10,7 @@ trait CategorieFormAwareTrait { /** * @return CategorieForm */ - public function getCategorieForm() + public function getCategorieForm() : CategorieForm { return $this->categoriePrivilegeForm; } @@ -19,7 +19,7 @@ trait CategorieFormAwareTrait { * @param CategorieForm $categoriePrivilegeForm * @return CategorieForm */ - public function setCategorieForm($categoriePrivilegeForm) + public function setCategorieForm(CategorieForm $categoriePrivilegeForm) : CategorieForm { $this->categoriePrivilegeForm = $categoriePrivilegeForm; return $this->categoriePrivilegeForm; diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieFormFactory.php b/src/UnicaenPrivilege/Form/Categorie/CategorieFormFactory.php index 91f7acd29f1deb7061e42c1be739d1ca6ab25c9d..1f943a44df215eb8c7b07cbc4b43a4ed3cb9c41e 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieFormFactory.php +++ b/src/UnicaenPrivilege/Form/Categorie/CategorieFormFactory.php @@ -7,7 +7,7 @@ use Interop\Container\ContainerInterface; class CategorieFormFactory { - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : CategorieForm { /** * @var EntityManager $entitymanager diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieHydrator.php b/src/UnicaenPrivilege/Form/Categorie/CategorieHydrator.php index 8d60985380e1f8601b09f61be240e0936f40f392..1b7a05efd8cccf56feee84205e4c3dff3b63d217 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieHydrator.php +++ b/src/UnicaenPrivilege/Form/Categorie/CategorieHydrator.php @@ -11,7 +11,7 @@ class CategorieHydrator implements HydratorInterface { * @param Categorie $object * @return array */ - public function extract($object) + public function extract($object) : array { $data = [ 'libelle' => $object->getLibelle(), diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieHydratorFactory.php b/src/UnicaenPrivilege/Form/Categorie/CategorieHydratorFactory.php index 70b0a21022a558e4ef0088e1226f652693ccc533..f588b6a63971f91c0f67b3323993fc252e4e8c57 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieHydratorFactory.php +++ b/src/UnicaenPrivilege/Form/Categorie/CategorieHydratorFactory.php @@ -6,7 +6,7 @@ use Interop\Container\ContainerInterface; class CategorieHydratorFactory { - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : CategorieHydrator { /** @var CategorieHydrator $hydrator */ $hydrator = new CategorieHydrator(); diff --git a/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormAwareTrait.php b/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormAwareTrait.php index b4cc5b2c0ef40174b97220db9b91bb0238c69586..b3eef86794aa03a50bb4a7d9f9cd57d8b0808f2c 100644 --- a/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormAwareTrait.php +++ b/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormAwareTrait.php @@ -10,7 +10,7 @@ trait PrivilegeFormAwareTrait { /** * @return PrivilegeForm */ - public function getPrivilegeForm() + public function getPrivilegeForm() : PrivilegeForm { return $this->privilegeForm; } @@ -19,7 +19,7 @@ trait PrivilegeFormAwareTrait { * @param PrivilegeForm $privilegeForm * @return PrivilegeForm */ - public function setPrivilegeForm($privilegeForm) + public function setPrivilegeForm(PrivilegeForm $privilegeForm) : PrivilegeForm { $this->privilegeForm = $privilegeForm; return $this->privilegeForm; diff --git a/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php b/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php index 8639e8cb792cc7f386e366c1e9844ee2b81debb4..dcd7dce30d3ce539b0f5dae64a4e01a475861b2a 100644 --- a/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php +++ b/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php @@ -7,7 +7,7 @@ use Interop\Container\ContainerInterface; class PrivilegeFormFactory { - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : PrivilegeForm { /** * @var EntityManager $entitymanager diff --git a/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydrator.php b/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydrator.php index 19cd248ba831cf24a4ad8b7865fbc1649f602214..f7bca2c71cb87e6eaa8a18406c92a3852e6ac8f9 100644 --- a/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydrator.php +++ b/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydrator.php @@ -11,7 +11,7 @@ class PrivilegeHydrator implements HydratorInterface { * @param Privilege $object * @return array */ - public function extract($object) + public function extract($object) : array { $data = [ 'libelle' => $object->getLibelle(), diff --git a/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydratorFactory.php b/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydratorFactory.php index 257077186e6856c3b278c225102e2fe1d9b84e76..ef14e4de0605a02ed6853233fc2a708b0d542971 100644 --- a/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydratorFactory.php +++ b/src/UnicaenPrivilege/Form/Privilege/PrivilegeHydratorFactory.php @@ -6,7 +6,7 @@ use Interop\Container\ContainerInterface; class PrivilegeHydratorFactory { - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : PrivilegeHydrator { /** @var PrivilegeHydrator $hydrator */ $hydrator = new PrivilegeHydrator(); diff --git a/src/UnicaenPrivilege/Guard/PrivilegeControllerFactory.php b/src/UnicaenPrivilege/Guard/PrivilegeControllerFactory.php index 1d3bf1f7ac8434c66b80c78c12a96c9a17ca94b6..fd35a9046320a847edb52af5a78d3d7d34eb89c1 100644 --- a/src/UnicaenPrivilege/Guard/PrivilegeControllerFactory.php +++ b/src/UnicaenPrivilege/Guard/PrivilegeControllerFactory.php @@ -8,7 +8,7 @@ use UnicaenPrivilege\Service\Privilege\PrivilegeService; class PrivilegeControllerFactory { - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : PrivilegeController { /** @var PrivilegeProviderInterface $privilegeService */ $privilegeProvider = $container->get(PrivilegeService::class); diff --git a/src/UnicaenPrivilege/Guard/PrivilegeRouteFactory.php b/src/UnicaenPrivilege/Guard/PrivilegeRouteFactory.php index b0d789410b9b4e74e776c6b746098051761d9449..f375a69ef3cab1a26022d5bf607e43644c05f4af 100644 --- a/src/UnicaenPrivilege/Guard/PrivilegeRouteFactory.php +++ b/src/UnicaenPrivilege/Guard/PrivilegeRouteFactory.php @@ -9,7 +9,7 @@ use UnicaenPrivilege\Service\Privilege\PrivilegeService; class PrivilegeRouteFactory { - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : PrivilegeRoute { /** @var PrivilegeProviderInterface $privilegeService */ $privilegeProvider = $container->get(PrivilegeService::class); diff --git a/view/unicaen-privilege/categorie/index.phtml b/view/unicaen-privilege/categorie/index.phtml index 5d075432fdd584fd30bc9e6676952474b87c0eb3..aeb86d34013dc65c8d990ec8d6dabdbb6b79eca9 100644 --- a/view/unicaen-privilege/categorie/index.phtml +++ b/view/unicaen-privilege/categorie/index.phtml @@ -59,7 +59,7 @@ $canProvider = $this->isAllowed(PrivilegePrivileges::getResourceId(PrivilegeP <th> Ordre </th> <th> Namespace </th> <th> #Privilège </th> - <th> Action </th> + <th style="min-width:10rem;"> Action </th> </tr> </thead> <tbody>