diff --git a/config/merged/categorie.config.php b/config/merged/categorie.config.php deleted file mode 100644 index 54ed7708a07c2c7962a79971af4cc77711925a11..0000000000000000000000000000000000000000 --- a/config/merged/categorie.config.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php - -use UnicaenPrivilege\Controller\CategorieController; -use UnicaenPrivilege\Controller\CategorieControllerFactory; -use UnicaenPrivilege\Form\Categorie\CategorieFiltreForm; -use UnicaenPrivilege\Form\Categorie\CategorieFiltreFormFactory; -use UnicaenPrivilege\Form\Categorie\CategorieForm; -use UnicaenPrivilege\Form\Categorie\CategorieFormFactory; -use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; -use UnicaenPrivilege\Service\Categorie\CategorieService; -use UnicaenPrivilege\Service\Categorie\CategorieServiceFactory; -use Zend\Router\Http\Literal; -use Zend\Router\Http\Segment; - -return [ - - 'bjyauthorize' => [ - 'guards' => [ - UnicaenPrivilege\Guard\PrivilegeController::class => [ - [ - 'controller' => CategorieController::class, - 'action' => [ - 'index', - 'ajouter', - 'gerer', - 'provider', - 'modifier', - 'supprimer', - ], - 'privileges' => [ - PrivilegePrivileges::PRIVILEGE_AJOUTER, - ], - ], - ], - ], - ], - - 'router' => [ - 'routes' => [ - 'unicaen-privilege' => [ - 'child_routes' => [ - 'categorie' => [ - 'type' => Literal::class, - 'options' => [ - 'route' => '/categorie', - 'defaults' => [ - 'controller' => CategorieController::class, - 'action' => 'index', - ], - ], - 'may_terminate' => true, - 'child_routes' => [ - 'ajouter' => [ - 'type' => Literal::class, - 'options' => [ - 'route' => '/ajouter', - 'defaults' => [ - 'controller' => CategorieController::class, - 'action' => 'ajouter', - ], - ], - ], - 'gerer' => [ - 'type' => Segment::class, - 'options' => [ - 'route' => '/gerer/:categorie', - 'defaults' => [ - 'controller' => CategorieController::class, - 'action' => 'gerer', - ], - ], - 'may_terminate' => true, - ], - 'provider' => [ - 'type' => Segment::class, - 'options' => [ - 'route' => '/provider/:categorie', - 'defaults' => [ - 'controller' => CategorieController::class, - 'action' => 'provider', - ], - ], - 'may_terminate' => true, - ], - 'modifier' => [ - 'type' => Segment::class, - 'options' => [ - 'route' => '/modifier/:categorie', - 'defaults' => [ - 'controller' => CategorieController::class, - 'action' => 'modifier', - ], - ], - 'may_terminate' => true, - ], - 'supprimer' => [ - 'type' => Segment::class, - 'options' => [ - 'route' => '/supprimer/:categorie', - 'defaults' => [ - 'controller' => CategorieController::class, - 'action' => 'supprimer', - ], - ], - 'may_terminate' => true, - ], - ], - ], - ], - ], - ], - ], - - 'navigation' => [ - 'default' => [ - ], - ], - - 'controllers' => [ - 'factories' => [ - CategorieController::class => CategorieControllerFactory::class, - ], - ], - - 'service_manager' => [ - 'factories' => [ - CategorieService::class => CategorieServiceFactory::class, - ], - ], - - 'form_elements' => [ - 'factories' => [ - CategorieForm::class => CategorieFormFactory::class, - CategorieFiltreForm::class => CategorieFiltreFormFactory::class, - ], - ], -]; \ No newline at end of file diff --git a/config/merged/privilege.config.php b/config/merged/privilege.config.php index 051c963a369d2c813dc415dbd9e880127b845a26..cd63fa0729476f61ac8f7fcd401974e2a15e8f59 100644 --- a/config/merged/privilege.config.php +++ b/config/merged/privilege.config.php @@ -1,12 +1,20 @@ <?php +use UnicaenPrivilege\Controller\PrivilegeCategorieController; +use UnicaenPrivilege\Controller\PrivilegeCategorieControllerFactory; use UnicaenPrivilege\Controller\PrivilegeController; use UnicaenPrivilege\Controller\PrivilegeControllerFactory; +use UnicaenPrivilege\Form\Privilege\CategorieFiltreForm; +use UnicaenPrivilege\Form\Privilege\CategorieFiltreFormFactory; +use UnicaenPrivilege\Form\Privilege\CategorieForm; +use UnicaenPrivilege\Form\Privilege\CategorieFormFactory; use UnicaenPrivilege\Form\Privilege\PrivilegeForm; use UnicaenPrivilege\Form\Privilege\PrivilegeFormFactory; use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; use UnicaenPrivilege\Provider\Rule\PrivilegeRuleProvider; use UnicaenPrivilege\Provider\Rule\PrivilegeRuleProviderFactory; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceFactory; use UnicaenPrivilege\Service\Privilege\PrivilegeService; use UnicaenPrivilege\Service\Privilege\PrivilegeServiceFactory; use UnicaenPrivilege\View\Privilege\PrivilegeViewHelper; @@ -63,6 +71,20 @@ return [ PrivilegePrivileges::PRIVILEGE_SUPPRIMER, ], ], + [ + 'controller' => PrivilegeCategorieController::class, + 'action' => [ + 'index', + 'ajouter', + 'gerer', + 'provider', + 'modifier', + 'supprimer', + ], + 'privileges' => [ + PrivilegePrivileges::PRIVILEGE_AJOUTER, + ], + ], ], ], ], @@ -120,6 +142,73 @@ return [ ], ], ], + 'categorie' => [ + 'type' => Literal::class, + 'options' => [ + 'route' => '/categorie', + 'defaults' => [ + 'controller' => PrivilegeCategorieController::class, + 'action' => 'index', + ], + ], + 'may_terminate' => true, + 'child_routes' => [ + 'ajouter' => [ + 'type' => Literal::class, + 'options' => [ + 'route' => '/ajouter', + 'defaults' => [ + 'controller' => PrivilegeCategorieController::class, + 'action' => 'ajouter', + ], + ], + ], + 'gerer' => [ + 'type' => Segment::class, + 'options' => [ + 'route' => '/gerer/:categorie', + 'defaults' => [ + 'controller' => PrivilegeCategorieController::class, + 'action' => 'gerer', + ], + ], + 'may_terminate' => true, + ], + 'provider' => [ + 'type' => Segment::class, + 'options' => [ + 'route' => '/provider/:categorie', + 'defaults' => [ + 'controller' => PrivilegeCategorieController::class, + 'action' => 'provider', + ], + ], + 'may_terminate' => true, + ], + 'modifier' => [ + 'type' => Segment::class, + 'options' => [ + 'route' => '/modifier/:categorie', + 'defaults' => [ + 'controller' => PrivilegeCategorieController::class, + 'action' => 'modifier', + ], + ], + 'may_terminate' => true, + ], + 'supprimer' => [ + 'type' => Segment::class, + 'options' => [ + 'route' => '/supprimer/:categorie', + 'defaults' => [ + 'controller' => PrivilegeCategorieController::class, + 'action' => 'supprimer', + ], + ], + 'may_terminate' => true, + ], + ], + ], ], ], ], @@ -127,12 +216,14 @@ return [ 'controllers' => [ 'factories' => [ + PrivilegeCategorieController::class => PrivilegeCategorieControllerFactory::class, PrivilegeController::class => PrivilegeControllerFactory::class, ], ], 'service_manager' => [ 'factories' => [ + PrivilegeCategorieService::class => PrivilegeCategorieServiceFactory::class, PrivilegeService::class => PrivilegeServiceFactory::class, PrivilegeRuleProvider::class => PrivilegeRuleProviderFactory::class, ], @@ -140,6 +231,8 @@ return [ 'form_elements' => [ 'factories' => [ + CategorieFiltreForm::class => CategorieFiltreFormFactory::class, + CategorieForm::class => CategorieFormFactory::class, PrivilegeForm::class => PrivilegeFormFactory::class, ], ], diff --git a/src/UnicaenPrivilege/Controller/CategorieController.php b/src/UnicaenPrivilege/Controller/PrivilegeCategorieController.php similarity index 72% rename from src/UnicaenPrivilege/Controller/CategorieController.php rename to src/UnicaenPrivilege/Controller/PrivilegeCategorieController.php index a5df2e39d1af9809c7cf1cbb8679444202329731..5d2161d5d77fb1ef68eb55235e1a38765c9f601b 100644 --- a/src/UnicaenPrivilege/Controller/CategorieController.php +++ b/src/UnicaenPrivilege/Controller/PrivilegeCategorieController.php @@ -2,18 +2,16 @@ namespace UnicaenPrivilege\Controller; -use UnicaenPrivilege\Entity\Db\CategorieInterface; -use UnicaenPrivilege\Form\Categorie\CategorieFiltreFormAwareTrait; -use UnicaenPrivilege\Form\Categorie\CategorieFormAwareTrait; -use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; +use UnicaenPrivilege\Form\Privilege\CategorieFiltreFormAwareTrait; +use UnicaenPrivilege\Form\Privilege\CategorieFormAwareTrait; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceAwareTrait; use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait; -use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; -class CategorieController extends AbstractActionController +class PrivilegeCategorieController extends AbstractActionController { - use CategorieServiceAwareTrait; + use PrivilegeCategorieServiceAwareTrait; use PrivilegeServiceAwareTrait; use CategorieFormAwareTrait; use CategorieFiltreFormAwareTrait; @@ -24,20 +22,20 @@ class CategorieController extends AbstractActionController $namespace = $this->params()->fromQuery('namespace'); if($namespace) { $form->get('namespace')->setValue($namespace); - $categories = $this->categorieService->findByNamespace($namespace); + $categories = $this->privilegeCategorieService->findByNamespace($namespace); } else { - $categories = $this->categorieService->findAll(); + $categories = $this->privilegeCategorieService->findAll(); } - $title = "Gestion des catégories"; + $title = "Gestion des catégories de privilèges"; return compact('title', 'form', 'categories'); } public function ajouterAction() : ViewModel { - $categorie = $this->categorieService->getEntityInstance(); - $categorie->setOrdre($this->categorieService->getMaxOrdre()+1); + $categorie = $this->privilegeCategorieService->getEntityInstance(); + $categorie->setOrdre($this->privilegeCategorieService->getMaxOrdre()+1); $form = $this->categorieForm; $form->setAttribute('action', $this->url()->fromRoute('unicaen-privilege/categorie/ajouter', [], [], true)); $form->bind($categorie); @@ -46,7 +44,7 @@ class CategorieController extends AbstractActionController $form->setData($data); if ($form->isValid()) { try { - $this->categorieService->create($categorie); + $this->privilegeCategorieService->create($categorie); $this->flashMessenger()->addSuccessMessage(sprintf("Catégorie <strong>%s</strong> créée avec succès.", $categorie->getLibelle())); } catch (Exception $e) { $this->flashMessenger()->addErrorMessage(sprintf("Une erreur est survenu lors de la création de la catégorie <strong>%s</strong>.", $categorie->getLibelle())); @@ -66,7 +64,7 @@ class CategorieController extends AbstractActionController public function gererAction() : array { - $categorie = $this->categorieService->getRequestedCategorie($this); + $categorie = $this->privilegeCategorieService->getRequestedCategorie($this); $privileges = $this->privilegeService->findByCategorie($categorie); $title = "Gestion de la catégorie"; @@ -75,14 +73,14 @@ class CategorieController extends AbstractActionController public function providerAction() : array { - $categorie = $this->categorieService->getRequestedCategorie($this); + $categorie = $this->privilegeCategorieService->getRequestedCategorie($this); return compact('categorie'); } public function modifierAction() : ViewModel { - $categorie = $this->categorieService->getRequestedCategorie($this); + $categorie = $this->privilegeCategorieService->getRequestedCategorie($this); $form = $this->categorieForm; $form->setAttribute('action', $this->url()->fromRoute('unicaen-privilege/categorie/modifier', ['categorie' => $categorie->getId()], [], true)); $form->bind($categorie); @@ -91,7 +89,7 @@ class CategorieController extends AbstractActionController $form->setData($data); if ($form->isValid()) { try { - $this->categorieService->update($categorie); + $this->privilegeCategorieService->update($categorie); $this->flashMessenger()->addSuccessMessage(sprintf("Catégorie <strong>%s</strong> modifiée avec succès.", $categorie->getLibelle())); } catch (Exception $e) { $this->flashMessenger()->addErrorMessage(sprintf("Une erreur est survenu lors de la modification de la catégorie <strong>%s</strong>.", $categorie->getLibelle())); @@ -100,7 +98,7 @@ class CategorieController extends AbstractActionController } $view = new ViewModel(); - $view->setTemplate('unicaen-privilege/categorie/template/form-categorie'); + $view->setTemplate('unicaen-privilege/privilege-categorie/template/form-categorie'); $view->setVariables([ 'title' => "Modification de la catégorie", 'form' => $form, @@ -113,8 +111,8 @@ class CategorieController extends AbstractActionController public function supprimerAction() : array { try { - $categorie = $this->categorieService->getRequestedCategorie($this); - $this->categorieService->delete($categorie); + $categorie = $this->privilegeCategorieService->getRequestedCategorie($this); + $this->privilegeCategorieService->delete($categorie); $this->flashMessenger()->addSuccessMessage(sprintf("Catégorie <strong>%s</strong> supprimée avec succès.", $categorie->getLibelle())); } catch (Exception $e) { $this->flashMessenger()->addErrorMessage(sprintf("Une erreur est survenu lors de la suppression de la catégorie <strong>%s</strong>.", $categorie->getLibelle())); diff --git a/src/UnicaenPrivilege/Controller/CategorieControllerFactory.php b/src/UnicaenPrivilege/Controller/PrivilegeCategorieControllerFactory.php similarity index 64% rename from src/UnicaenPrivilege/Controller/CategorieControllerFactory.php rename to src/UnicaenPrivilege/Controller/PrivilegeCategorieControllerFactory.php index da8dcce90840bddac9419a641e97a3c14c61752d..38ad0f6375f12c4a26912c586e64e097ab0aec1f 100644 --- a/src/UnicaenPrivilege/Controller/CategorieControllerFactory.php +++ b/src/UnicaenPrivilege/Controller/PrivilegeCategorieControllerFactory.php @@ -3,12 +3,12 @@ namespace UnicaenPrivilege\Controller; use Interop\Container\ContainerInterface; -use UnicaenPrivilege\Form\Categorie\CategorieFiltreForm; -use UnicaenPrivilege\Form\Categorie\CategorieForm; -use UnicaenPrivilege\Service\Categorie\CategorieService; +use UnicaenPrivilege\Form\Privilege\CategorieFiltreForm; +use UnicaenPrivilege\Form\Privilege\CategorieForm; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService; use UnicaenPrivilege\Service\Privilege\PrivilegeService; -class CategorieControllerFactory +class PrivilegeCategorieControllerFactory { /** * Create controller @@ -16,21 +16,21 @@ class CategorieControllerFactory * @param ContainerInterface $container * @param string $requestedName * @param array|null $options - * @return CategorieController|object + * @return PrivilegeCategorieController|object */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /** - * @var CategorieService $categorieService + * @var PrivilegeCategorieService $categorieService * @var PrivilegeService $privilegeService */ - $categorieService = $container->get(CategorieService::class); + $categorieService = $container->get(PrivilegeCategorieService::class); $privilegeService = $container->get(PrivilegeService::class); $categorieForm = $container->get('FormElementManager')->get(CategorieForm::class); $categorieFiltreForm = $container->get('FormElementManager')->get(CategorieFiltreForm::class); - $controller = new CategorieController(); - $controller->setCategorieService($categorieService); + $controller = new PrivilegeCategorieController(); + $controller->setPrivilegeCategorieService($categorieService); $controller->setPrivilegeService($privilegeService); $controller->setCategorieForm($categorieForm); $controller->setCategorieFiltreForm($categorieFiltreForm); diff --git a/src/UnicaenPrivilege/Controller/PrivilegeController.php b/src/UnicaenPrivilege/Controller/PrivilegeController.php index 899c901b5cc3ecf16f658622023aa79a7b0addce..f159b974f99e910f565eec19b18b0ae474e2dd2b 100644 --- a/src/UnicaenPrivilege/Controller/PrivilegeController.php +++ b/src/UnicaenPrivilege/Controller/PrivilegeController.php @@ -2,19 +2,17 @@ namespace UnicaenPrivilege\Controller; -use UnicaenPrivilege\Form\Categorie\CategorieFiltreFormAwareTrait; +use UnicaenPrivilege\Form\Privilege\CategorieFiltreFormAwareTrait; use UnicaenPrivilege\Form\Privilege\PrivilegeFormAwareTrait; -use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceAwareTrait; use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait; use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait; -use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; -use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; class PrivilegeController extends AbstractActionController { - use CategorieServiceAwareTrait; + use PrivilegeCategorieServiceAwareTrait; use PrivilegeServiceAwareTrait; use RoleServiceAwareTrait; use PrivilegeFormAwareTrait; @@ -37,7 +35,7 @@ class PrivilegeController extends AbstractActionController public function ajouterAction() : ViewModel { - $categorie = $this->categorieService->getRequestedCategorie($this); + $categorie = $this->privilegeCategorieService->getRequestedCategorie($this); $privilege = $this->privilegeService->getEntityInstance(); $privilege->setOrdre($this->privilegeService->getMaxOrdreByCategorie($categorie)+1); $privilege->setCategorie($categorie); diff --git a/src/UnicaenPrivilege/Controller/PrivilegeControllerFactory.php b/src/UnicaenPrivilege/Controller/PrivilegeControllerFactory.php index 83eb0d3a40df13f0511d95f063baecbaf33da431..fdf6886777ed00a7de1a690e04c0c2fea05f0a5c 100644 --- a/src/UnicaenPrivilege/Controller/PrivilegeControllerFactory.php +++ b/src/UnicaenPrivilege/Controller/PrivilegeControllerFactory.php @@ -3,9 +3,9 @@ namespace UnicaenPrivilege\Controller; use Interop\Container\ContainerInterface; -use UnicaenPrivilege\Form\Categorie\CategorieFiltreForm; +use UnicaenPrivilege\Form\Privilege\CategorieFiltreForm; use UnicaenPrivilege\Form\Privilege\PrivilegeForm; -use UnicaenPrivilege\Service\Categorie\CategorieService; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService; use UnicaenPrivilege\Service\Privilege\PrivilegeService; use UnicaenUtilisateur\Service\Role\RoleService; @@ -22,18 +22,18 @@ class PrivilegeControllerFactory public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /** - * @var CategorieService $categorieService + * @var PrivilegeCategorieService $categorieService * @var PrivilegeService $privilegeService * @var RoleService $roleService */ - $categorieService = $container->get(CategorieService::class); + $categorieService = $container->get(PrivilegeCategorieService::class); $privilegeService = $container->get(PrivilegeService::class); $roleService = $container->get(RoleService::class); $privilegeForm = $container->get('FormElementManager')->get(PrivilegeForm::class); $categorieFiltreForm = $container->get('FormElementManager')->get(CategorieFiltreForm::class); $controller = new PrivilegeController(); - $controller->setCategorieService($categorieService); + $controller->setPrivilegeCategorieService($categorieService); $controller->setPrivilegeService($privilegeService); $controller->setRoleService($roleService); $controller->setPrivilegeForm($privilegeForm); diff --git a/src/UnicaenPrivilege/Entity/Db/AbstractPrivilege.php b/src/UnicaenPrivilege/Entity/Db/AbstractPrivilege.php index c6968dbcc9b51c50a41537b417b1c5d91b50640e..82d131f55cae469fa97e75bf07b8fc0b67e672da 100644 --- a/src/UnicaenPrivilege/Entity/Db/AbstractPrivilege.php +++ b/src/UnicaenPrivilege/Entity/Db/AbstractPrivilege.php @@ -31,7 +31,7 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac protected $ordre; /** - * @var CategorieInterface + * @var PrivilegeCategorieInterface */ protected $categorie; @@ -163,7 +163,7 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * Get categorie. * - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function getCategorie() { @@ -173,10 +173,10 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * Set categorie. * - * @param CategorieInterface $categorie + * @param PrivilegeCategorieInterface $categorie * @return PrivilegeInterface */ - public function setCategorie(CategorieInterface $categorie) + public function setCategorie(PrivilegeCategorieInterface $categorie) { $this->categorie = $categorie; diff --git a/src/UnicaenPrivilege/Entity/Db/AbstractCategorie.php b/src/UnicaenPrivilege/Entity/Db/AbstractPrivilegeCategorie.php similarity index 89% rename from src/UnicaenPrivilege/Entity/Db/AbstractCategorie.php rename to src/UnicaenPrivilege/Entity/Db/AbstractPrivilegeCategorie.php index c4773c64fdc682f3a485e4c3f8d36706476f3d30..1cc3a0ceb6d0d1cde973329b678116b060139ac3 100644 --- a/src/UnicaenPrivilege/Entity/Db/AbstractCategorie.php +++ b/src/UnicaenPrivilege/Entity/Db/AbstractPrivilegeCategorie.php @@ -5,7 +5,7 @@ namespace UnicaenPrivilege\Entity\Db; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -abstract class AbstractCategorie implements CategorieInterface +abstract class AbstractPrivilegeCategorie implements PrivilegeCategorieInterface { /** * @var int @@ -68,7 +68,7 @@ abstract class AbstractCategorie implements CategorieInterface * Set id. * * @param int $id - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setId($id) { @@ -91,7 +91,7 @@ abstract class AbstractCategorie implements CategorieInterface * Set code. * * @param string $code - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setCode($code) { @@ -114,7 +114,7 @@ abstract class AbstractCategorie implements CategorieInterface * Set libelle. * * @param string $libelle - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setLibelle($libelle) { @@ -137,7 +137,7 @@ abstract class AbstractCategorie implements CategorieInterface * Set namespace. * * @param string $namespace - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setNamespace($namespace) { @@ -160,7 +160,7 @@ abstract class AbstractCategorie implements CategorieInterface * Set ordre. * * @param int $ordre - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setOrdre($ordre) { @@ -183,7 +183,7 @@ abstract class AbstractCategorie implements CategorieInterface * Add privilege. * * @param PrivilegeInterface $privilege - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function addPrivilege(PrivilegeInterface $privilege) { @@ -196,7 +196,7 @@ abstract class AbstractCategorie implements CategorieInterface * Remove privilege. * * @param PrivilegeInterface $privilege - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function removePrivilege(PrivilegeInterface $privilege) { diff --git a/src/UnicaenPrivilege/Entity/Db/Categorie.php b/src/UnicaenPrivilege/Entity/Db/Categorie.php deleted file mode 100644 index 85f09841b47476d470a3bd9c42511a98dd0583d6..0000000000000000000000000000000000000000 --- a/src/UnicaenPrivilege/Entity/Db/Categorie.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -namespace UnicaenPrivilege\Entity\Db; - -class Categorie extends AbstractCategorie {} \ No newline at end of file diff --git a/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Categorie.dcm.xml b/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Categorie.dcm.xml index c6ff64e20644a6eb053349f90aad9b4c8a26af5b..bb8d191879a098ce5dccfee7f76c337387704de5 100644 --- a/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Categorie.dcm.xml +++ b/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Categorie.dcm.xml @@ -2,7 +2,7 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="UnicaenPrivilege\Entity\Db\Categorie" table="UNICAEN_PRIVILEGE_CATEGORIE"> + <entity name="UnicaenPrivilege\Entity\Db\PrivilegeCategorie" table="UNICAEN_PRIVILEGE_CATEGORIE"> <unique-constraints> <unique-constraint name="un_unicaen_privilege_categorie_code" columns="CODE"/> diff --git a/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Privilege.dcm.xml b/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Privilege.dcm.xml index 5811d02bd08f77d732283811ea43a9480d3b23f0..673529ee37998522b19df80d2d2d9fb25da5b269 100644 --- a/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Privilege.dcm.xml +++ b/src/UnicaenPrivilege/Entity/Db/Mapping/UnicaenPrivilege.Entity.Db.Privilege.dcm.xml @@ -20,7 +20,7 @@ <field name="libelle" type="string" column="LIBELLE" length="200" nullable="false"/> <field name="ordre" type="integer" column="ORDRE" nullable="false"/> - <many-to-one field="categorie" target-entity="UnicaenPrivilege\Entity\Db\Categorie" fetch="LAZY"> + <many-to-one field="categorie" target-entity="UnicaenPrivilege\Entity\Db\PrivilegeCategorie" fetch="LAZY"> <join-columns> <join-column name="CATEGORIE_ID" referenced-column-name="ID"/> </join-columns> diff --git a/src/UnicaenPrivilege/Entity/Db/PrivilegeCategorie.php b/src/UnicaenPrivilege/Entity/Db/PrivilegeCategorie.php new file mode 100644 index 0000000000000000000000000000000000000000..753d29b964e3ec57e599b14c10033d09eedb751b --- /dev/null +++ b/src/UnicaenPrivilege/Entity/Db/PrivilegeCategorie.php @@ -0,0 +1,5 @@ +<?php + +namespace UnicaenPrivilege\Entity\Db; + +class PrivilegeCategorie extends AbstractPrivilegeCategorie {} \ No newline at end of file diff --git a/src/UnicaenPrivilege/Entity/Db/CategorieInterface.php b/src/UnicaenPrivilege/Entity/Db/PrivilegeCategorieInterface.php similarity index 83% rename from src/UnicaenPrivilege/Entity/Db/CategorieInterface.php rename to src/UnicaenPrivilege/Entity/Db/PrivilegeCategorieInterface.php index b6c18382e42332de9700442f1c5d03940de17375..a752c906c37c84e48040d653472148a2140e6965 100644 --- a/src/UnicaenPrivilege/Entity/Db/CategorieInterface.php +++ b/src/UnicaenPrivilege/Entity/Db/PrivilegeCategorieInterface.php @@ -4,7 +4,7 @@ namespace UnicaenPrivilege\Entity\Db; use Doctrine\Common\Collections\Collection; -interface CategorieInterface +interface PrivilegeCategorieInterface { /** * @return string @@ -22,7 +22,7 @@ interface CategorieInterface * Set id. * * @param int $id - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setId($id); @@ -37,7 +37,7 @@ interface CategorieInterface * Set code. * * @param string $code - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setCode($code); @@ -52,7 +52,7 @@ interface CategorieInterface * Set libelle. * * @param string $libelle - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setLibelle($libelle); @@ -67,7 +67,7 @@ interface CategorieInterface * Set namespace. * * @param string $namespace - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setNamespace($namespace); @@ -82,7 +82,7 @@ interface CategorieInterface * Set ordre. * * @param int $ordre - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function setOrdre($ordre); @@ -97,7 +97,7 @@ interface CategorieInterface * Add privilege. * * @param PrivilegeInterface $privilege - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function addPrivilege(PrivilegeInterface $privilege); @@ -105,7 +105,7 @@ interface CategorieInterface * Remove privilege. * * @param PrivilegeInterface $privilege - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function removePrivilege(PrivilegeInterface $privilege); diff --git a/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php b/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php index b5e45cc30bfe3686613bb7fa960a7ef26f63869e..a2306294cd950dfc6357456a882aa6c79e72e0da 100644 --- a/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php +++ b/src/UnicaenPrivilege/Entity/Db/PrivilegeInterface.php @@ -84,17 +84,17 @@ interface PrivilegeInterface /** * Get categorie. * - * @return CategorieInterface + * @return PrivilegeCategorieInterface */ public function getCategorie(); /** * Set categorie. * - * @param CategorieInterface $categorie + * @param PrivilegeCategorieInterface $categorie * @return PrivilegeInterface */ - public function setCategorie(CategorieInterface $categorie); + public function setCategorie(PrivilegeCategorieInterface $categorie); /** * @return Collection diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieFiltreForm.php b/src/UnicaenPrivilege/Form/Privilege/CategorieFiltreForm.php similarity index 82% rename from src/UnicaenPrivilege/Form/Categorie/CategorieFiltreForm.php rename to src/UnicaenPrivilege/Form/Privilege/CategorieFiltreForm.php index eb474e02f5025289f22e43f08b9d8dc9ffae5538..3c55abc64a75fd10fd903bb3cf50f1ed6c444d4b 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieFiltreForm.php +++ b/src/UnicaenPrivilege/Form/Privilege/CategorieFiltreForm.php @@ -1,20 +1,18 @@ <?php -namespace UnicaenPrivilege\Form\Categorie; +namespace UnicaenPrivilege\Form\Privilege; -use DoctrineModule\Form\Element\ObjectSelect; use UnicaenApp\Service\EntityManagerAwareTrait; -use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Select; -use Zend\Form\Element\Submit; use Zend\Form\Form; use Zend\InputFilter\Factory; class CategorieFiltreForm extends Form { use EntityManagerAwareTrait; - use CategorieServiceAwareTrait; + use PrivilegeCategorieServiceAwareTrait; public function init() { @@ -25,8 +23,8 @@ class CategorieFiltreForm extends Form 'name' => 'namespace', 'options' => [ 'empty_option' => "Tous les namespaces", - 'value_options' => $this->categorieService->getListForSelect( - $this->categorieService->findAllWithNamespace(), 'namespace', 'namespace' + 'value_options' => $this->privilegeCategorieService->getListForSelect( + $this->privilegeCategorieService->findAllWithNamespace(), 'namespace', 'namespace' ), ], 'attributes' => [ diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieFiltreFormAwareTrait.php b/src/UnicaenPrivilege/Form/Privilege/CategorieFiltreFormAwareTrait.php similarity index 93% rename from src/UnicaenPrivilege/Form/Categorie/CategorieFiltreFormAwareTrait.php rename to src/UnicaenPrivilege/Form/Privilege/CategorieFiltreFormAwareTrait.php index 0f574477addbf3608727c70d33e724cd5dd25251..df8b200b0ed8f864a0605f09a5848192d0ec7029 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieFiltreFormAwareTrait.php +++ b/src/UnicaenPrivilege/Form/Privilege/CategorieFiltreFormAwareTrait.php @@ -1,6 +1,6 @@ <?php -namespace UnicaenPrivilege\Form\Categorie; +namespace UnicaenPrivilege\Form\Privilege; trait CategorieFiltreFormAwareTrait { diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieFiltreFormFactory.php b/src/UnicaenPrivilege/Form/Privilege/CategorieFiltreFormFactory.php similarity index 64% rename from src/UnicaenPrivilege/Form/Categorie/CategorieFiltreFormFactory.php rename to src/UnicaenPrivilege/Form/Privilege/CategorieFiltreFormFactory.php index e3c6ee4edbda183f936a030fcc3fdffb923100ee..c33b8eec2a5834c56c15b7613ce331a2b7138de3 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieFiltreFormFactory.php +++ b/src/UnicaenPrivilege/Form/Privilege/CategorieFiltreFormFactory.php @@ -1,12 +1,10 @@ <?php -namespace UnicaenPrivilege\Form\Categorie; +namespace UnicaenPrivilege\Form\Privilege; use Doctrine\ORM\EntityManager; -use DoctrineModule\Stdlib\Hydrator\DoctrineObject; use Interop\Container\ContainerInterface; -use UnicaenPrivilege\Service\Categorie\CategorieService; -use UnicaenUtilisateur\Service\Role\RoleService; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService; class CategorieFiltreFormFactory { @@ -22,14 +20,14 @@ class CategorieFiltreFormFactory { /** * @var EntityManager $entityManager - * @var RoleService $categorieService + * @var PrivilegeCategorieService $categorieService */ $entityManager = $container->get('Doctrine\ORM\EntityManager'); - $categorieService = $container->get(CategorieService::class); + $categorieService = $container->get(PrivilegeCategorieService::class); $form = new CategorieFiltreForm(); $form->setEntityManager($entityManager); - $form->setCategorieService($categorieService); + $form->setPrivilegeCategorieService($categorieService); return $form; } diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieForm.php b/src/UnicaenPrivilege/Form/Privilege/CategorieForm.php similarity index 93% rename from src/UnicaenPrivilege/Form/Categorie/CategorieForm.php rename to src/UnicaenPrivilege/Form/Privilege/CategorieForm.php index 521b93128fe2a114d8dee6261fe89de58072c342..75257063b7eb90e5a869b00fae58ea33e4ccfbe2 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieForm.php +++ b/src/UnicaenPrivilege/Form/Privilege/CategorieForm.php @@ -1,12 +1,10 @@ <?php -namespace UnicaenPrivilege\Form\Categorie; +namespace UnicaenPrivilege\Form\Privilege; -use DoctrineModule\Validator\UniqueObject; use UnicaenApp\Service\EntityManagerAwareTrait; -use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceAwareTrait; use Zend\Form\Element\Button; -use Zend\Form\Element\Hidden; use Zend\Form\Element\Number; use Zend\Form\Element\Text; use Zend\Form\Form; @@ -18,7 +16,7 @@ use Zend\Validator\Regex; class CategorieForm extends Form { use EntityManagerAwareTrait; - use CategorieServiceAwareTrait; + use PrivilegeCategorieServiceAwareTrait; public function init() { @@ -109,7 +107,7 @@ class CategorieForm extends Form Callback::INVALID_VALUE => "Ce libellé est déjà utilisé pour une autre catégorie.", ], 'callback' => function ($value, $context = []) { - $categorie = $this->categorieService->findByLibelle($value); + $categorie = $this->privilegeCategorieService->findByLibelle($value); if(!$categorie) { return true; } @@ -153,7 +151,7 @@ class CategorieForm extends Form Callback::INVALID_VALUE => "Ce code est déjà utilisé pour une autre catégorie.", ], 'callback' => function ($value, $context = []) { - $categorie = $this->categorieService->findByCode($value); + $categorie = $this->privilegeCategorieService->findByCode($value); if(!$categorie) { return true; } diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieFormAwareTrait.php b/src/UnicaenPrivilege/Form/Privilege/CategorieFormAwareTrait.php similarity index 92% rename from src/UnicaenPrivilege/Form/Categorie/CategorieFormAwareTrait.php rename to src/UnicaenPrivilege/Form/Privilege/CategorieFormAwareTrait.php index 608ad9b9adf71c3cb6aed05bb2958dccbf0ac3f9..8c6604b80ffdc3fdfc0a9aa6a46fb749099f09ae 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieFormAwareTrait.php +++ b/src/UnicaenPrivilege/Form/Privilege/CategorieFormAwareTrait.php @@ -1,6 +1,6 @@ <?php -namespace UnicaenPrivilege\Form\Categorie; +namespace UnicaenPrivilege\Form\Privilege; trait CategorieFormAwareTrait { diff --git a/src/UnicaenPrivilege/Form/Categorie/CategorieFormFactory.php b/src/UnicaenPrivilege/Form/Privilege/CategorieFormFactory.php similarity index 72% rename from src/UnicaenPrivilege/Form/Categorie/CategorieFormFactory.php rename to src/UnicaenPrivilege/Form/Privilege/CategorieFormFactory.php index ebef1a0eb5979292cc164ef3dcf05f6be185e896..96ff0217262026f9604becc01d3d61f43d43e0f8 100644 --- a/src/UnicaenPrivilege/Form/Categorie/CategorieFormFactory.php +++ b/src/UnicaenPrivilege/Form/Privilege/CategorieFormFactory.php @@ -1,11 +1,11 @@ <?php -namespace UnicaenPrivilege\Form\Categorie; +namespace UnicaenPrivilege\Form\Privilege; use Doctrine\ORM\EntityManager; use DoctrineModule\Stdlib\Hydrator\DoctrineObject; use Interop\Container\ContainerInterface; -use UnicaenPrivilege\Service\Categorie\CategorieService; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService; class CategorieFormFactory { @@ -21,15 +21,15 @@ class CategorieFormFactory { /** * @var EntityManager $entityManager - * @var CategorieService $categorieService + * @var PrivilegeCategorieService $categorieService */ $entityManager = $container->get('Doctrine\ORM\EntityManager'); - $categorieService = $container->get(CategorieService::class); + $categorieService = $container->get(PrivilegeCategorieService::class); $hydrator = $container->get('HydratorManager')->get(DoctrineObject::class); $form = new CategorieForm(); $form->setEntityManager($entityManager); - $form->setCategorieService($categorieService); + $form->setPrivilegeCategorieService($categorieService); $form->setHydrator($hydrator); return $form; diff --git a/src/UnicaenPrivilege/Form/Privilege/PrivilegeForm.php b/src/UnicaenPrivilege/Form/Privilege/PrivilegeForm.php index 9650ec48c6ed2beee6e7f5701df959dfe0160091..3cddaf9afaa771613578c304e11e800d1fd3c060 100644 --- a/src/UnicaenPrivilege/Form/Privilege/PrivilegeForm.php +++ b/src/UnicaenPrivilege/Form/Privilege/PrivilegeForm.php @@ -4,11 +4,8 @@ namespace UnicaenPrivilege\Form\Privilege; use DoctrineModule\Form\Element\ObjectSelect; -use DoctrineModule\Validator\NoObjectExists; -use DoctrineModule\Validator\UniqueObject; use UnicaenApp\Service\EntityManagerAwareTrait; -use UnicaenPrivilege\Entity\Db\CategorieInterface; -use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceAwareTrait; use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Hidden; @@ -23,7 +20,7 @@ use Zend\Validator\Regex; class PrivilegeForm extends Form { use EntityManagerAwareTrait; - use CategorieServiceAwareTrait; + use PrivilegeCategorieServiceAwareTrait; use PrivilegeServiceAwareTrait; public function init() @@ -41,7 +38,7 @@ class PrivilegeForm extends Form 'options' => [ 'label' => "Catégorie :", 'object_manager' => $this->getEntityManager(), - 'target_class' => $this->categorieService->getEntityClass(), + 'target_class' => $this->privilegeCategorieService->getEntityClass(), 'property' => 'libelle', 'find_method' => [ 'name' => 'findBy', @@ -133,7 +130,7 @@ class PrivilegeForm extends Form Callback::INVALID_VALUE => "Ce libellé est déjà utilisé pour un autre privilège de cette catégorie.", ], 'callback' => function ($value, $context = []) { - $categorie = $this->categorieService->find($context['categorieId']); + $categorie = $this->privilegeCategorieService->find($context['categorieId']); $privilege = $this->privilegeService->findByLibelle($value, $categorie); if(!$privilege) { return true; @@ -178,7 +175,7 @@ class PrivilegeForm extends Form Callback::INVALID_VALUE => "Ce code est déjà utilisé pour un autre privilège de cette catégorie.", ], 'callback' => function ($value, $context = []) { - $categorie = $this->categorieService->find($context['categorieId']); + $categorie = $this->privilegeCategorieService->find($context['categorieId']); $privilege = $this->privilegeService->findByCode($value, $categorie); if(!$privilege) { return true; diff --git a/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php b/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php index b8640df724f3146632c4b1506c288c427a998562..bb685fc6eff6145a6eeb5fa8184e6f21f417557c 100644 --- a/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php +++ b/src/UnicaenPrivilege/Form/Privilege/PrivilegeFormFactory.php @@ -5,7 +5,7 @@ namespace UnicaenPrivilege\Form\Privilege; use Doctrine\ORM\EntityManager; use DoctrineModule\Stdlib\Hydrator\DoctrineObject; use Interop\Container\ContainerInterface; -use UnicaenPrivilege\Service\Categorie\CategorieService; +use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService; use UnicaenPrivilege\Service\Privilege\PrivilegeService; class PrivilegeFormFactory @@ -22,17 +22,17 @@ class PrivilegeFormFactory { /** * @var EntityManager $entityManager - * @var CategorieService $categorieService + * @var PrivilegeCategorieService $categorieService * @var PrivilegeService $privilegeService */ $entityManager = $container->get('Doctrine\ORM\EntityManager'); - $categorieService = $container->get(CategorieService::class); + $categorieService = $container->get(PrivilegeCategorieService::class); $privilegeService = $container->get(PrivilegeService::class); $hydrator = $container->get('HydratorManager')->get(DoctrineObject::class); $form = new PrivilegeForm(); $form->setEntityManager($entityManager); - $form->setCategorieService($categorieService); + $form->setPrivilegeCategorieService($categorieService); $form->setPrivilegeService($privilegeService); $form->setHydrator($hydrator); diff --git a/src/UnicaenPrivilege/Service/Categorie/CategorieServiceAwareTrait.php b/src/UnicaenPrivilege/Service/Categorie/CategorieServiceAwareTrait.php deleted file mode 100644 index 62bcd7f76918cf9e04b2a8099a1edf4a02388624..0000000000000000000000000000000000000000 --- a/src/UnicaenPrivilege/Service/Categorie/CategorieServiceAwareTrait.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -namespace UnicaenPrivilege\Service\Categorie; - -trait CategorieServiceAwareTrait -{ - /** - * @var CategorieService - */ - private $categorieService; - - /** - * @param CategorieService $categorieService - * @return CategorieService - */ - public function setCategorieService(CategorieService $categorieService): CategorieService - { - $this->categorieService = $categorieService; - - return $this->categorieService; - } - - /** - * @return CategorieService - */ - public function getCategorieService(): CategorieService - { - return $this->categorieService; - } -} \ No newline at end of file diff --git a/src/UnicaenPrivilege/Service/Categorie/CategorieService.php b/src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieService.php similarity index 75% rename from src/UnicaenPrivilege/Service/Categorie/CategorieService.php rename to src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieService.php index 3e101a0d93403dbb8a094275645dafc57a0ea369..f5c36940ff61aa4cd6a8047a2197ad6d08389fad 100644 --- a/src/UnicaenPrivilege/Service/Categorie/CategorieService.php +++ b/src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieService.php @@ -1,27 +1,22 @@ <?php -namespace UnicaenPrivilege\Service\Categorie; +namespace UnicaenPrivilege\Service\Privilege; -use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\ORMException; -use Doctrine\ORM\QueryBuilder; use UnicaenApp\Exception\RuntimeException; -use UnicaenApp\Service\EntityManagerAwareTrait; -use UnicaenPrivilege\Entity\Db\CategorieInterface; -use UnicaenPrivilege\Entity\Db\PrivilegeInterface; +use UnicaenPrivilege\Entity\Db\PrivilegeCategorieInterface; use UnicaenPrivilege\Service\CommonService; use Zend\Mvc\Controller\AbstractActionController; -class CategorieService extends CommonService +class PrivilegeCategorieService extends CommonService { /** * @param string $categorieEntityClass */ public function setEntityClass($categorieEntityClass) { - if (! class_exists($categorieEntityClass) || ! in_array(CategorieInterface::class, class_implements($categorieEntityClass))) { - throw new InvalidArgumentException("L'entité associée aux catégories de privilège doit implémenter " . CategorieInterface::class); + if (! class_exists($categorieEntityClass) || ! in_array(PrivilegeCategorieInterface::class, class_implements($categorieEntityClass))) { + throw new InvalidArgumentException("L'entité associée aux catégories de privilège doit implémenter " . PrivilegeCategorieInterface::class); } $this->entityClass = $categorieEntityClass; @@ -29,7 +24,7 @@ class CategorieService extends CommonService /** * @param array $orderBy - * @return CategorieInterface[] + * @return PrivilegeCategorieInterface[] */ public function findAll(array $orderBy = ['ordre' => 'ASC']) { @@ -78,10 +73,10 @@ class CategorieService extends CommonService } /** - * @param CategorieInterface $categorie - * @return CategorieInterface + * @param PrivilegeCategorieInterface $categorie + * @return PrivilegeCategorieInterface */ - public function create(CategorieInterface $categorie) + public function create(PrivilegeCategorieInterface $categorie) { try { $this->getEntityManager()->persist($categorie); @@ -94,10 +89,10 @@ class CategorieService extends CommonService } /** - * @param CategorieInterface $categorie - * @return CategorieInterface + * @param PrivilegeCategorieInterface $categorie + * @return PrivilegeCategorieInterface */ - public function update(CategorieInterface $categorie) + public function update(PrivilegeCategorieInterface $categorie) { try { $this->getEntityManager()->flush($categorie); @@ -109,10 +104,10 @@ class CategorieService extends CommonService } /** - * @param CategorieInterface $categorie - * @return CategorieInterface + * @param PrivilegeCategorieInterface $categorie + * @return PrivilegeCategorieInterface */ - public function delete(CategorieInterface $categorie) : CategorieInterface + public function delete(PrivilegeCategorieInterface $categorie) : PrivilegeCategorieInterface { try { $this->getEntityManager()->remove($categorie); @@ -128,7 +123,7 @@ class CategorieService extends CommonService /** * @param AbstractActionController $controller * @param string $param - * @return CategorieInterface|null + * @return PrivilegeCategorieInterface|null */ public function getRequestedCategorie(AbstractActionController $controller, string $param = 'categorie') { diff --git a/src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieServiceAwareTrait.php b/src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieServiceAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..e9d9e1eb0df1f6fe56e8a8cb9cff72c8c68206b4 --- /dev/null +++ b/src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieServiceAwareTrait.php @@ -0,0 +1,30 @@ +<?php + +namespace UnicaenPrivilege\Service\Privilege; + +trait PrivilegeCategorieServiceAwareTrait +{ + /** + * @var PrivilegeCategorieService + */ + private $privilegeCategorieService; + + /** + * @param PrivilegeCategorieService $privilegeCategorieService + * @return PrivilegeCategorieService + */ + public function setPrivilegeCategorieService(PrivilegeCategorieService $privilegeCategorieService): PrivilegeCategorieService + { + $this->privilegeCategorieService = $privilegeCategorieService; + + return $this->privilegeCategorieService; + } + + /** + * @return PrivilegeCategorieService + */ + public function getPrivilegeCategorieService(): PrivilegeCategorieService + { + return $this->privilegeCategorieService; + } +} \ No newline at end of file diff --git a/src/UnicaenPrivilege/Service/Categorie/CategorieServiceFactory.php b/src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieServiceFactory.php similarity index 84% rename from src/UnicaenPrivilege/Service/Categorie/CategorieServiceFactory.php rename to src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieServiceFactory.php index a977166b77ee7be12d69f13391195e77df975f4d..d48fbadbc71ae5b0ad59dee8d496010c1f5b5da0 100644 --- a/src/UnicaenPrivilege/Service/Categorie/CategorieServiceFactory.php +++ b/src/UnicaenPrivilege/Service/Privilege/PrivilegeCategorieServiceFactory.php @@ -1,12 +1,12 @@ <?php -namespace UnicaenPrivilege\Service\Categorie; +namespace UnicaenPrivilege\Service\Privilege; use Doctrine\ORM\EntityManager; use Interop\Container\ContainerInterface; use UnicaenPrivilege\Entity\Db\Privilege; -class CategorieServiceFactory +class PrivilegeCategorieServiceFactory { /** * Create service @@ -14,7 +14,7 @@ class CategorieServiceFactory * @param ContainerInterface $container * @param string $requestedName * @param array|null $options - * @return CategorieService + * @return PrivilegeCategorieService */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { @@ -27,7 +27,7 @@ class CategorieServiceFactory $privilegeEntityClass = $config['unicaen-auth']['privilege_entity_class'] ?? Privilege::class; $mapping = $entityManager->getClassMetadata($privilegeEntityClass)->getAssociationMapping('categorie'); - $service = new CategorieService(); + $service = new PrivilegeCategorieService(); $service->setEntityManager($entityManager); $service->setEntityClass($mapping['targetEntity']); diff --git a/src/UnicaenPrivilege/Service/Privilege/PrivilegeService.php b/src/UnicaenPrivilege/Service/Privilege/PrivilegeService.php index 37edc002cf764460e4fee6ccc6daa472cff1d7f4..021636a65830145acf1880f3b11b5ed452fd181b 100644 --- a/src/UnicaenPrivilege/Service/Privilege/PrivilegeService.php +++ b/src/UnicaenPrivilege/Service/Privilege/PrivilegeService.php @@ -6,19 +6,18 @@ use BjyAuthorize\Provider\Resource\ProviderInterface as ResourceProviderInterfac use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; use Doctrine\ORM\ORMException; -use UnicaenPrivilege\Entity\Db\CategorieInterface; +use UnicaenPrivilege\Entity\Db\PrivilegeCategorieInterface; use UnicaenPrivilege\Entity\Db\PrivilegeInterface; use UnicaenPrivilege\Exception\RuntimeException; use UnicaenPrivilege\Provider\Privilege\PrivilegeProviderInterface; use UnicaenPrivilege\Provider\Privilege\Privileges; -use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; use UnicaenPrivilege\Service\CommonService; use UnicaenUtilisateur\Entity\Db\RoleInterface; use Zend\Mvc\Controller\AbstractActionController; class PrivilegeService extends CommonService implements PrivilegeProviderInterface, ResourceProviderInterface { - use CategorieServiceAwareTrait; + use PrivilegeCategorieServiceAwareTrait; /** * @var array @@ -41,7 +40,7 @@ class PrivilegeService extends CommonService implements PrivilegeProviderInterfa /** * @param string $code - * @param int|CategorieInterface $categorie + * @param int|PrivilegeCategorieInterface $categorie * @return PrivilegeInterface|null */ public function findByCode(string $code, $categorie) @@ -51,7 +50,7 @@ class PrivilegeService extends CommonService implements PrivilegeProviderInterfa /** * @param string $libelle - * @param int|CategorieInterface $categorie + * @param int|PrivilegeCategorieInterface $categorie * @return PrivilegeInterface|null */ public function findByLibelle(string $libelle, $categorie) @@ -60,11 +59,11 @@ class PrivilegeService extends CommonService implements PrivilegeProviderInterfa } /** - * @param CategorieInterface $categorie + * @param PrivilegeCategorieInterface $categorie * @param array $orderBy * @return array */ - public function findByCategorie(CategorieInterface $categorie, array $orderBy = ['ordre' => 'ASC']) + public function findByCategorie(PrivilegeCategorieInterface $categorie, array $orderBy = ['ordre' => 'ASC']) { return $this->getRepo()->findBy(['categorie' => $categorie], $orderBy); } @@ -76,8 +75,8 @@ class PrivilegeService extends CommonService implements PrivilegeProviderInterfa public function listByCategorie(?string $namespace) { $categories = $namespace - ? $this->categorieService->findByNamespace($namespace) - : $this->categorieService->findAll(); + ? $this->privilegeCategorieService->findByNamespace($namespace) + : $this->privilegeCategorieService->findAll(); $privilegesByCategorie = []; foreach ($categories as $c) { @@ -207,12 +206,12 @@ class PrivilegeService extends CommonService implements PrivilegeProviderInterfa } /** - * @param CategorieInterface $categorie + * @param PrivilegeCategorieInterface $categorie * @return float|int|mixed|string * @throws NonUniqueResultException * @throws NoResultException */ - public function getMaxOrdreByCategorie(CategorieInterface $categorie) + public function getMaxOrdreByCategorie(PrivilegeCategorieInterface $categorie) { $qb = $this->getRepo()->createQueryBuilder('p'); $qb ->select($qb->expr()->max('p.ordre')) diff --git a/src/UnicaenPrivilege/Service/Privilege/PrivilegeServiceFactory.php b/src/UnicaenPrivilege/Service/Privilege/PrivilegeServiceFactory.php index e74717d816c9bcbb500ac3349c48e2a161dbd55f..d5721ba0a72816ace8668da1d7794b36c3e8bbe7 100644 --- a/src/UnicaenPrivilege/Service/Privilege/PrivilegeServiceFactory.php +++ b/src/UnicaenPrivilege/Service/Privilege/PrivilegeServiceFactory.php @@ -6,7 +6,6 @@ use Doctrine\ORM\EntityManager; use Interop\Container\ContainerInterface; use UnicaenPrivilege\Entity\Db\Privilege; use UnicaenPrivilege\Service\Affectation\AffectationService; -use UnicaenPrivilege\Service\Categorie\CategorieService; class PrivilegeServiceFactory { @@ -22,15 +21,15 @@ class PrivilegeServiceFactory { /** * @var EntityManager $entityManager - * @var CategorieService $categorieService + * @var PrivilegeCategorieService $categorieService */ $entityManager = $container->get('Doctrine\ORM\EntityManager'); $config = $container->get('Config'); - $categorieService = $container->get(CategorieService::class); + $categorieService = $container->get(PrivilegeCategorieService::class); $service = new PrivilegeService(); $service->setEntityManager($entityManager); - $service->setCategorieService($categorieService); + $service->setPrivilegeCategorieService($categorieService); $service->setEntityClass($config['unicaen-auth']['privilege_entity_class'] ?? Privilege::class); return $service; diff --git a/view/unicaen-privilege/categorie/gerer.phtml b/view/unicaen-privilege/privilege-categorie/gerer.phtml similarity index 96% rename from view/unicaen-privilege/categorie/gerer.phtml rename to view/unicaen-privilege/privilege-categorie/gerer.phtml index 1f4bb5a27518bade9bba3f5dcc1841f7bd0b0ba9..8a1da4e7517b52b2adbd49a8f6f3159c32f42113 100644 --- a/view/unicaen-privilege/categorie/gerer.phtml +++ b/view/unicaen-privilege/privilege-categorie/gerer.phtml @@ -1,13 +1,14 @@ <?php -use UnicaenPrivilege\Entity\Db\CategorieInterface; +use UnicaenPrivilege\Entity\Db\PrivilegeCategorieInterface; use UnicaenPrivilege\Entity\Db\PrivilegeInterface; use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; /** - * @see \UnicaenPrivilege\Controller\CategorieController::gererAction() - * @var CategorieInterface $categorie + * @var PrivilegeCategorieInterface $categorie * @var PrivilegeInterface[] $privileges + * + * @see PrivilegeCategorieController::gererAction() */ $canVoir = $this->isAllowed(PrivilegePrivileges::getResourceId(PrivilegePrivileges::PRIVILEGE_VOIR)); @@ -28,7 +29,7 @@ $canProvider = $this->isAllowed(PrivilegePrivileges::getResourceId(Pr <?php echo $this->messenger()->addMessagesFromFlashMessenger(); ?> <?php if ($canVoir) : ?> - <?php /** @see CategorieController::indexAction() */ ?> + <?php /** @see PrivilegeCategorieController::indexAction() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie', [], [], true); ?>" class="btn btn-primary"> <i class="fas fa-tag"></i> Gérer les catégories @@ -74,7 +75,7 @@ $canProvider = $this->isAllowed(PrivilegePrivileges::getResourceId(Pr </table> <div class="panel-footer"> <?php if ($canEditerCategorie) : ?> - <?php /** @see CategorieController::modifierAction()() */ ?> + <?php /** @see PrivilegeCategorieController::modifierAction()() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie/modifier', ['categorie' => $categorie->getId()], [], true); ?>" class="btn btn-primary ajax-modal" data-event="event-unicaen-privilege-editer"> <i class="fas fa-edit"></i> Modifier la catégorie @@ -90,7 +91,7 @@ $canProvider = $this->isAllowed(PrivilegePrivileges::getResourceId(Pr <?php endif; ?> <?php if ($canDetruireCategorie) : ?> - <?php /** @see CategorieController::supprimerAction() */ ?> + <?php /** @see PrivilegeCategorieController::supprimerAction() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie/supprimer', ['categorie' => $categorie->getId()], [], true); ?>" class="btn btn-danger pop-ajax" data-confirm="true" diff --git a/view/unicaen-privilege/categorie/index.phtml b/view/unicaen-privilege/privilege-categorie/index.phtml similarity index 92% rename from view/unicaen-privilege/categorie/index.phtml rename to view/unicaen-privilege/privilege-categorie/index.phtml index e3f06ee895aaadd230cf24ccba1cffae57494e25..57a1a54619fbc4050e31b3a65961f8e3c0acc1e6 100644 --- a/view/unicaen-privilege/categorie/index.phtml +++ b/view/unicaen-privilege/privilege-categorie/index.phtml @@ -1,14 +1,14 @@ <?php -use UnicaenPrivilege\Entity\Db\CategorieInterface; +use UnicaenPrivilege\Entity\Db\PrivilegeCategorieInterface; use UnicaenPrivilege\Entity\Db\PrivilegeInterface; use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; /** * @var string $title - * @var CategorieInterface[] $categories + * @var PrivilegeCategorieInterface[] $categories * - * @see CategorieController::indexAction() + * @see PrivilegeCategorieController::indexAction() */ $canAffecter = $this->isAllowed(PrivilegePrivileges::getResourceId(PrivilegePrivileges::PRIVILEGE_ATTRIBUER)); @@ -40,7 +40,7 @@ $canProvider = $this->isAllowed(PrivilegePrivileges::getResourceId(PrivilegeP <?php endif; ?> <?php if ($canAjouter): ?> - <?php /** @see CategorieController::ajouterAction() */ ?> + <?php /** @see PrivilegeCategorieController::ajouterAction() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie/ajouter', [], [], true); ?>" class="btn btn-primary ajax-modal" data-event="event-unicaen-privilege-categorie-editer"> @@ -98,7 +98,7 @@ $canProvider = $this->isAllowed(PrivilegePrivileges::getResourceId(PrivilegeP <tr> <td> <?php if ($canVoir) : ?> - <?php /** @see CategorieController::gererAction() */ ?> + <?php /** @see PrivilegeCategorieController::gererAction() */ ?> <a title="Gérer la catégorie et ses privilèges" href="<?php echo $this->url('unicaen-privilege/categorie/gerer', ['categorie' => $categorie->getId()], [], true); ?>"> <?php endif; ?> <?php echo $categorie->getLibelle(); ?> @@ -118,18 +118,18 @@ $canProvider = $this->isAllowed(PrivilegePrivileges::getResourceId(PrivilegeP <td><?php echo $categorie->getOrdre(); ?></td> <td> <?php if ($canModifier) : ?> - <?php /** @see CategorieController::modifierAction() */ ?> + <?php /** @see PrivilegeCategorieController::modifierAction() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie/modifier', ['categorie' => $categorie->getId()], [], true); ?>" class="ajax-modal" data-event="event-unicaen-privilege-categorie-editer"> <i class="fas fa-edit" title="Modifier la catégorie"></i></a> <?php endif; ?> <?php if ($canProvider) : ?> - <?php /** @see CategorieController::providerAction() */ ?> + <?php /** @see PrivilegeCategorieController::providerAction() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie/provider', ['categorie' => $categorie->getId()], [], true); ?>" class="ajax-modal"> <i class="fas fa-code" title='Afficher le fichier "Provider"'></i></a> <?php endif; ?> <?php if ($canDetruire) : ?> - <?php /** @see CategorieController::supprimerAction() */ ?> + <?php /** @see PrivilegeCategorieController::supprimerAction() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie/supprimer', ['categorie' => $categorie->getId()], [], true); ?>" class="pop-ajax" data-confirm="true" diff --git a/view/unicaen-privilege/categorie/provider.phtml b/view/unicaen-privilege/privilege-categorie/provider.phtml similarity index 90% rename from view/unicaen-privilege/categorie/provider.phtml rename to view/unicaen-privilege/privilege-categorie/provider.phtml index 21364047b6db77dd7b2f8ffa6a6700f6989f70f8..449999a4fcc68d783640d84960e184f2ab6802d4 100644 --- a/view/unicaen-privilege/categorie/provider.phtml +++ b/view/unicaen-privilege/privilege-categorie/provider.phtml @@ -1,10 +1,10 @@ <?php -use UnicaenPrivilege\Entity\Db\CategorieInterface; +use UnicaenPrivilege\Entity\Db\PrivilegeCategorieInterface; use UnicaenPrivilege\Entity\Db\PrivilegeInterface; /** - * @var CategorieInterface $categorie + * @var PrivilegeCategorieInterface $categorie */ $namespace = ($categorie->getNamespace() ? $categorie->getNamespace() : "<span class='missing-data'>NONE_GIVEN</span>"); diff --git a/view/unicaen-privilege/categorie/supprimer.phtml b/view/unicaen-privilege/privilege-categorie/supprimer.phtml similarity index 63% rename from view/unicaen-privilege/categorie/supprimer.phtml rename to view/unicaen-privilege/privilege-categorie/supprimer.phtml index c91f9bbe1efeef06a9cfff2591f77340b5585fb8..30f9df65226ee1a513c6f977cdadfab11e012436 100644 --- a/view/unicaen-privilege/categorie/supprimer.phtml +++ b/view/unicaen-privilege/privilege-categorie/supprimer.phtml @@ -1,11 +1,9 @@ <?php -use UnicaenPrivilege\Entity\Db\CategorieInterface; +use UnicaenPrivilege\Entity\Db\PrivilegeCategorieInterface; /** - * @var CategorieInterface $role - * - * @see CategorieController::supprimerAction() + * @see PrivilegeCategorieController::supprimerAction() */ ?> diff --git a/view/unicaen-privilege/categorie/template/form-categorie.phtml b/view/unicaen-privilege/privilege-categorie/template/form-categorie.phtml similarity index 74% rename from view/unicaen-privilege/categorie/template/form-categorie.phtml rename to view/unicaen-privilege/privilege-categorie/template/form-categorie.phtml index 20cd4c7fe886fac4a277e2954f9bdec6f70089cd..29c92d89a1b652ea0dbb62ad21027c481dbb7491 100644 --- a/view/unicaen-privilege/categorie/template/form-categorie.phtml +++ b/view/unicaen-privilege/privilege-categorie/template/form-categorie.phtml @@ -1,6 +1,6 @@ <?php -use UnicaenPrivilege\Form\Categorie\CategorieForm; +use UnicaenPrivilege\Form\Privilege\CategorieForm; /** * @var CategorieForm $form diff --git a/view/unicaen-privilege/privilege/index.phtml b/view/unicaen-privilege/privilege/index.phtml index 44c9701abb1db18226801d087fe723ec5bc8a7f6..65e86442083cd647541fbdbb791da7dddbbaf767 100644 --- a/view/unicaen-privilege/privilege/index.phtml +++ b/view/unicaen-privilege/privilege/index.phtml @@ -21,7 +21,7 @@ use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; <?php echo $this->messenger()->addMessagesFromFlashMessenger(); ?> -<?php /** @see CategorieController::indexAction() */ ?> +<?php /** @see PrivilegeCategorieController::indexAction() */ ?> <a href="<?php echo $this->url('unicaen-privilege/categorie', [], []); ?>" class="btn btn-primary"> <i class="fas fa-crown"></i>