Loading config/merged/affectation.config.php +7 −4 Original line number Diff line number Diff line Loading @@ -3,9 +3,10 @@ use UnicaenPrivilege\Controller\AffectationController; use UnicaenPrivilege\Controller\AffectationControllerFactory; use UnicaenPrivilege\Controller\ConfigurationController; use UnicaenPrivilege\Controller\ConfigurationControllerFactory; use UnicaenPrivilege\Guard\PrivilegeController; use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; use UnicaenPrivilege\Service\Affectation\AffectationService; use UnicaenPrivilege\Service\Affectation\AffectationServiceFactory; use Zend\Router\Http\Literal; use Zend\Router\Http\Segment; Loading Loading @@ -38,7 +39,7 @@ return [ 'privilege' => [ 'label' => 'Privilège', 'route' => 'unicaen-privilege/affectation', 'resource' => \UnicaenPrivilege\Guard\PrivilegeController::getResourceId(AffectationController::class, 'index'), 'resource' => PrivilegeController::getResourceId(AffectationController::class, 'index'), 'order' => 5000, ], ], Loading Loading @@ -83,7 +84,9 @@ return [ ], 'service_manager' => [ 'factories' => [], 'factories' => [ AffectationService::class => AffectationServiceFactory::class, ], ], 'controllers' => [ 'factories' => [ Loading src/UnicaenPrivilege/Controller/AffectationController.php +5 −12 Original line number Diff line number Diff line Loading @@ -2,16 +2,16 @@ namespace UnicaenPrivilege\Controller; use UnicaenPrivilege\Entity\Db\Privilege; use UnicaenPrivilege\Service\Affectation\AffectationServiceAwareTrait; use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait; use UnicaenUtilisateur\Entity\Db\Role; use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; class AffectationController extends AbstractActionController { use AffectationServiceAwareTrait; use CategorieServiceAwareTrait; use RoleServiceAwareTrait; use PrivilegeServiceAwareTrait; Loading @@ -33,17 +33,10 @@ class AffectationController extends AbstractActionController { public function modifierAction() : JsonModel { $privilegeId = $this->params()->fromRoute("privilege"); $roleId = $this->params()->fromRoute("role"); /** * @var Privilege $privilege * @var Role $role */ $privilege = $this->getPrivilegeService()->getRequestedPrivilege($this); $role = $this->getRoleService()->getRequestedRole($this); $privilege = $this->getPrivilegeService()->getPrivilege($privilegeId); $role = $this->getPrivilegeService()->getRole($roleId); $value = $this->getPrivilegeService()->toggle($role,$privilege); $value = $this->getAffectationService()->toggle($role,$privilege); return new JsonModel([ 'value' => $value, Loading src/UnicaenPrivilege/Controller/AffectationControllerFactory.php +4 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenPrivilege\Controller; use Interop\Container\ContainerInterface; use UnicaenPrivilege\Service\Affectation\AffectationService; use UnicaenPrivilege\Service\Categorie\CategorieService; use UnicaenPrivilege\Service\Privilege\PrivilegeService; use UnicaenUtilisateur\Service\Role\RoleService; Loading @@ -12,16 +13,19 @@ class AffectationControllerFactory { public function __invoke(ContainerInterface $container) : AffectationController { /** * @var AffectationService $affectationService * @var CategorieService $categorieService * @var PrivilegeService $privilegeService * @var RoleService $roleService */ $affectationService = $container->get(AffectationService::class); $categorieService = $container->get(CategorieService::class); $privilegeService = $container->get(PrivilegeService::class); $roleService = $container->get(RoleService::class); /** @var AffectationController $controller*/ $controller = new AffectationController(); $controller->setAffectationService($affectationService); $controller->setCategorieService($categorieService); $controller->setPrivilegeService($privilegeService); $controller->setRoleService($roleService); Loading src/UnicaenPrivilege/Controller/PrivilegeController.php +0 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ class PrivilegeController extends AbstractActionController { public function supprimerAction() { $privilege = $this->getPrivilegeService()->getRequestedPrivilege($this); $categorie = $privilege->getCategorie(); /** @var Request $request */ $request = $this->getRequest(); Loading src/UnicaenPrivilege/Entity/Db/AbstractPrivilege.php +22 −44 Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ namespace UnicaenPrivilege\Entity\Db; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenPrivilege\Provider\Privilege\Privileges; use UnicaenUtilisateur\Entity\Db\RoleInterface; use Zend\Permissions\Acl\Resource\ResourceInterface; Loading Loading @@ -62,17 +65,14 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac */ public function __construct() { $this->role = new \Doctrine\Common\Collections\ArrayCollection(); $this->role = new ArrayCollection(); } /** * Set code * * @param string $code * * @return Privilege */ public function setCode($code) public function setCode(string $code) : PrivilegeInterface { $this->code = $code; Loading @@ -80,28 +80,23 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac } /** * Get code * * @return string */ public function getCode() public function getCode() : string { return $this->code; } public function getFullCode() public function getFullCode() : string { return $this->getCategorie()->getCode() . '-' . $this->getCode(); } /** * Set libelle * * @param string $libelle * * @return Privilege */ public function setLibelle($libelle) public function setLibelle(string $libelle) : PrivilegeInterface { $this->libelle = $libelle; Loading @@ -110,30 +105,26 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * Get libelle * * @return string */ public function getLibelle() public function getLibelle() : string { return $this->libelle; } /** * * @return integer */ function getOrdre() function getOrdre() : int { return $this->ordre; } /** * * @param integer $ordre * * @return self */ function setOrdre($ordre) function setOrdre(int $ordre) : PrivilegeInterface { $this->ordre = $ordre; Loading @@ -141,23 +132,18 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac } /** * Get id * * @return integer */ public function getId() public function getId() : int { return $this->id; } /** * Set categorie * * @param Categorie $categorie * * @param Categorie|null $categorie * @return self */ public function setCategorie(Categorie $categorie = null) public function setCategorie(?Categorie $categorie = null) : PrivilegeInterface { $this->categorie = $categorie; Loading @@ -165,45 +151,37 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac } /** * Get categorie * * @return Categorie */ public function getCategorie() public function getCategorie() : Categorie { return $this->categorie; } /** * Add role * * @param RoleInterface $role * * @return self */ public function addRole(RoleInterface $role) public function addRole(RoleInterface $role) : PrivilegeInterface { $this->role->add($role); return $this; } /** * Remove role * * @param RoleInterface $role * @return self */ public function removeRole(RoleInterface $role) public function removeRole(RoleInterface $role) : PrivilegeInterface { $this->role->removeElement($role); return $this; } /** * Get role * * @return Collection */ public function getRole() public function getRole() : Collection { return $this->role; } Loading @@ -211,7 +189,7 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * @return string */ public function __toString() public function __toString() : string { return $this->getLibelle(); } Loading @@ -219,7 +197,7 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * @return string */ public function getResourceId() public function getResourceId() : string { return Privileges::getResourceId($this); } Loading Loading
config/merged/affectation.config.php +7 −4 Original line number Diff line number Diff line Loading @@ -3,9 +3,10 @@ use UnicaenPrivilege\Controller\AffectationController; use UnicaenPrivilege\Controller\AffectationControllerFactory; use UnicaenPrivilege\Controller\ConfigurationController; use UnicaenPrivilege\Controller\ConfigurationControllerFactory; use UnicaenPrivilege\Guard\PrivilegeController; use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; use UnicaenPrivilege\Service\Affectation\AffectationService; use UnicaenPrivilege\Service\Affectation\AffectationServiceFactory; use Zend\Router\Http\Literal; use Zend\Router\Http\Segment; Loading Loading @@ -38,7 +39,7 @@ return [ 'privilege' => [ 'label' => 'Privilège', 'route' => 'unicaen-privilege/affectation', 'resource' => \UnicaenPrivilege\Guard\PrivilegeController::getResourceId(AffectationController::class, 'index'), 'resource' => PrivilegeController::getResourceId(AffectationController::class, 'index'), 'order' => 5000, ], ], Loading Loading @@ -83,7 +84,9 @@ return [ ], 'service_manager' => [ 'factories' => [], 'factories' => [ AffectationService::class => AffectationServiceFactory::class, ], ], 'controllers' => [ 'factories' => [ Loading
src/UnicaenPrivilege/Controller/AffectationController.php +5 −12 Original line number Diff line number Diff line Loading @@ -2,16 +2,16 @@ namespace UnicaenPrivilege\Controller; use UnicaenPrivilege\Entity\Db\Privilege; use UnicaenPrivilege\Service\Affectation\AffectationServiceAwareTrait; use UnicaenPrivilege\Service\Categorie\CategorieServiceAwareTrait; use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait; use UnicaenUtilisateur\Entity\Db\Role; use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; class AffectationController extends AbstractActionController { use AffectationServiceAwareTrait; use CategorieServiceAwareTrait; use RoleServiceAwareTrait; use PrivilegeServiceAwareTrait; Loading @@ -33,17 +33,10 @@ class AffectationController extends AbstractActionController { public function modifierAction() : JsonModel { $privilegeId = $this->params()->fromRoute("privilege"); $roleId = $this->params()->fromRoute("role"); /** * @var Privilege $privilege * @var Role $role */ $privilege = $this->getPrivilegeService()->getRequestedPrivilege($this); $role = $this->getRoleService()->getRequestedRole($this); $privilege = $this->getPrivilegeService()->getPrivilege($privilegeId); $role = $this->getPrivilegeService()->getRole($roleId); $value = $this->getPrivilegeService()->toggle($role,$privilege); $value = $this->getAffectationService()->toggle($role,$privilege); return new JsonModel([ 'value' => $value, Loading
src/UnicaenPrivilege/Controller/AffectationControllerFactory.php +4 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenPrivilege\Controller; use Interop\Container\ContainerInterface; use UnicaenPrivilege\Service\Affectation\AffectationService; use UnicaenPrivilege\Service\Categorie\CategorieService; use UnicaenPrivilege\Service\Privilege\PrivilegeService; use UnicaenUtilisateur\Service\Role\RoleService; Loading @@ -12,16 +13,19 @@ class AffectationControllerFactory { public function __invoke(ContainerInterface $container) : AffectationController { /** * @var AffectationService $affectationService * @var CategorieService $categorieService * @var PrivilegeService $privilegeService * @var RoleService $roleService */ $affectationService = $container->get(AffectationService::class); $categorieService = $container->get(CategorieService::class); $privilegeService = $container->get(PrivilegeService::class); $roleService = $container->get(RoleService::class); /** @var AffectationController $controller*/ $controller = new AffectationController(); $controller->setAffectationService($affectationService); $controller->setCategorieService($categorieService); $controller->setPrivilegeService($privilegeService); $controller->setRoleService($roleService); Loading
src/UnicaenPrivilege/Controller/PrivilegeController.php +0 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ class PrivilegeController extends AbstractActionController { public function supprimerAction() { $privilege = $this->getPrivilegeService()->getRequestedPrivilege($this); $categorie = $privilege->getCategorie(); /** @var Request $request */ $request = $this->getRequest(); Loading
src/UnicaenPrivilege/Entity/Db/AbstractPrivilege.php +22 −44 Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ namespace UnicaenPrivilege\Entity\Db; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenPrivilege\Provider\Privilege\Privileges; use UnicaenUtilisateur\Entity\Db\RoleInterface; use Zend\Permissions\Acl\Resource\ResourceInterface; Loading Loading @@ -62,17 +65,14 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac */ public function __construct() { $this->role = new \Doctrine\Common\Collections\ArrayCollection(); $this->role = new ArrayCollection(); } /** * Set code * * @param string $code * * @return Privilege */ public function setCode($code) public function setCode(string $code) : PrivilegeInterface { $this->code = $code; Loading @@ -80,28 +80,23 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac } /** * Get code * * @return string */ public function getCode() public function getCode() : string { return $this->code; } public function getFullCode() public function getFullCode() : string { return $this->getCategorie()->getCode() . '-' . $this->getCode(); } /** * Set libelle * * @param string $libelle * * @return Privilege */ public function setLibelle($libelle) public function setLibelle(string $libelle) : PrivilegeInterface { $this->libelle = $libelle; Loading @@ -110,30 +105,26 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * Get libelle * * @return string */ public function getLibelle() public function getLibelle() : string { return $this->libelle; } /** * * @return integer */ function getOrdre() function getOrdre() : int { return $this->ordre; } /** * * @param integer $ordre * * @return self */ function setOrdre($ordre) function setOrdre(int $ordre) : PrivilegeInterface { $this->ordre = $ordre; Loading @@ -141,23 +132,18 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac } /** * Get id * * @return integer */ public function getId() public function getId() : int { return $this->id; } /** * Set categorie * * @param Categorie $categorie * * @param Categorie|null $categorie * @return self */ public function setCategorie(Categorie $categorie = null) public function setCategorie(?Categorie $categorie = null) : PrivilegeInterface { $this->categorie = $categorie; Loading @@ -165,45 +151,37 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac } /** * Get categorie * * @return Categorie */ public function getCategorie() public function getCategorie() : Categorie { return $this->categorie; } /** * Add role * * @param RoleInterface $role * * @return self */ public function addRole(RoleInterface $role) public function addRole(RoleInterface $role) : PrivilegeInterface { $this->role->add($role); return $this; } /** * Remove role * * @param RoleInterface $role * @return self */ public function removeRole(RoleInterface $role) public function removeRole(RoleInterface $role) : PrivilegeInterface { $this->role->removeElement($role); return $this; } /** * Get role * * @return Collection */ public function getRole() public function getRole() : Collection { return $this->role; } Loading @@ -211,7 +189,7 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * @return string */ public function __toString() public function __toString() : string { return $this->getLibelle(); } Loading @@ -219,7 +197,7 @@ abstract class AbstractPrivilege implements PrivilegeInterface, ResourceInterfac /** * @return string */ public function getResourceId() public function getResourceId() : string { return Privileges::getResourceId($this); } Loading