Loading module/EntretienProfessionnel/config/merged/sursis.config.php +166 Changes for module/EntretienProfessionnel/config/merged/sursis.config.php: 166 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace EntretienProfessionnel; use EntretienProfessionnel\Controller\SursisController; use EntretienProfessionnel\Controller\SursisControllerFactory; use EntretienProfessionnel\Form\Sursis\SursisForm; use EntretienProfessionnel\Form\Sursis\SursisFormFactory; use EntretienProfessionnel\Form\Sursis\SursisHydrator; use EntretienProfessionnel\Form\Sursis\SursisHydratorFactory; use EntretienProfessionnel\Provider\Privilege\SursisPrivileges; use EntretienProfessionnel\Service\Sursis\SursisService; use EntretienProfessionnel\Service\Sursis\SursisServiceFactory; use UnicaenPrivilege\Guard\PrivilegeController; use Zend\Router\Http\Literal; use Zend\Router\Http\Segment; return [ 'bjyauthorize' => [ 'guards' => [ PrivilegeController::class => [ [ 'controller' => SursisController::class, 'action' => [ 'afficher', ], 'privileges' => [ SursisPrivileges::SURSIS_AFFICHER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'ajouter', ], 'privileges' => [ SursisPrivileges::SURSIS_AJOUTER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'modifier', ], 'privileges' => [ SursisPrivileges::SURSIS_MODIFIER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'historiser', 'restaurer', ], 'privileges' => [ SursisPrivileges::SURSIS_HISTORISER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'supprimer', ], 'privileges' => [ SursisPrivileges::SURSIS_SUPPRIMER, ], ], ], ], ], 'router' => [ 'routes' => [ 'entretien-professionnel' => [ 'child_routes' => [ 'sursis' => [ 'type' => Literal::class, 'may_terminate' => false, 'options' => [ 'route' => '/sursis', ], 'child_routes' => [ 'ajouter' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/ajouter/:entretien-professionnel', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'ajouter', ], ], ], 'modifier' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/modifier/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'modifier', ], ], ], 'historiser' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/historiser/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'historiser', ], ], ], 'restaurer' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/restaurer/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'restaurer', ], ], ], 'detruire' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/detruire/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'detruire', ], ], ], ] ], ], ], ], ], 'service_manager' => [ 'factories' => [ SursisService::class => SursisServiceFactory::class, ], ], 'controllers' => [ 'factories' => [ SursisController::class => SursisControllerFactory::class, ], ], 'form_elements' => [ 'factories' => [ SursisForm::class => SursisFormFactory::class, ], ], 'hydrators' => [ 'factories' => [ SursisHydrator::class => SursisHydratorFactory::class, ], ] ]; No newline at end of file module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisController.php +119 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisController.php: 119 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace EntretienProfessionnel\Controller; use EntretienProfessionnel\Entity\Db\Sursis; use EntretienProfessionnel\Form\Sursis\SursisFormAwareTrait; use EntretienProfessionnel\Service\EntretienProfessionnel\EntretienProfessionnelServiceAwareTrait; use EntretienProfessionnel\Service\Sursis\SursisServiceAwareTrait; use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class SursisController extends AbstractActionController { use EntretienProfessionnelServiceAwareTrait; use SursisServiceAwareTrait; use SursisFormAwareTrait; public function afficherAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); return new ViewModel([ 'title' => "Affichage du sursis", 'sursis' => $sursis, ]); } public function ajouterAction() { $entretien = $this->getEntretienProfessionnelService()->getRequestedEntretienProfessionnel($this); $sursis = new Sursis(); $sursis->setEntretien($entretien); $form = $this->getSursisForm(); $form->setAttribute('action', $this->url()->fromRoute('sursis/ajouter', ['entretien-professionnel' => $entretien->getId()], [], true)); $form->bind($sursis); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $this->getSursisService()->create($sursis); } } $vm = new ViewModel([ 'title' => "Ajout d'un sursis", 'form' => $form, ]); $vm->setTemplate('entretien-professionnel/default/default-form'); return $vm; } public function modifierAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); $form = $this->getSursisForm(); $form->setAttribute('action', $this->url()->fromRoute('sursis/modifier', ['sursis' => $sursis->getId()], [], true)); $form->bind($sursis); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $this->getSursisService()->update($sursis); } } $vm = new ViewModel([ 'title' => "Modification d'un sursis", 'form' => $form, ]); $vm->setTemplate('entretien-professionnel/default/default-form'); return $vm; } public function historiserAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); $retour = $this->params()->fromQuery('retour'); $this->getSursisService()->historise($sursis); return $this->redirect()->toUrl($retour); } public function restaurerAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); $retour = $this->params()->fromQuery('retour'); $this->getSursisService()->restore($sursis); return $this->redirect()->toUrl($retour); } public function supprimerAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); /** @var Request $request */ $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); if ($data["reponse"] === "oui") $this->getSursisService()->delete($sursis); exit(); } $vm = new ViewModel(); if ($sursis !== null) { $vm->setTemplate('entretien-professionnel/default/confirmation'); $vm->setVariables([ 'title' => "Suppression d'un sursis", 'text' => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?", 'action' => $this->url()->fromRoute('entretien-professionnel/default/supprimer', ["sursis" => $sursis->getId()], [], true), ]); } return $vm; } } No newline at end of file module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisControllerFactory.php +32 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisControllerFactory.php: 32 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace EntretienProfessionnel\Controller; use EntretienProfessionnel\Form\Sursis\SursisForm; use EntretienProfessionnel\Service\EntretienProfessionnel\EntretienProfessionnelService; use EntretienProfessionnel\Service\Sursis\SursisService; use Interop\Container\ContainerInterface; class SursisControllerFactory { public function __invoke(ContainerInterface $container) { /** * @var EntretienProfessionnelService $entretienService * @var SursisService $sursisService */ $entretienService = $container->get(EntretienProfessionnelService::class); $sursisService = $container->get(SursisService::class); /** * @var SursisForm $sursisForm */ $sursisForm = $container->get('FormElementManager')->get(SursisForm::class); $controller = new SursisController(); $controller->setEntretienProfessionnelService($entretienService); $controller->setSursisService($sursisService); $controller->setSursisForm($sursisForm); return $controller; } } No newline at end of file module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/EntretienProfessionnel.php +20 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/EntretienProfessionnel.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ class EntretienProfessionnel implements HistoriqueAwareInterface, ResourceInterf /** @var ArrayCollection (Observation) */ private $observations; /** @var ArrayCollection (Sursis) */ private $sursis; /** @var ValidationInstance */ private $validationAgent; Loading Loading @@ -262,6 +264,24 @@ class EntretienProfessionnel implements HistoriqueAwareInterface, ResourceInterf return $observation; } /** SURSIS ********************************************************************************************************/ /** * @return Sursis|null */ public function getSursisActive() : ?Sursis { $sursis = null; /** @var Sursis $item */ foreach ($this->sursis as $item) { if ($item->estNonHistorise()) { if ($sursis !== null) throw new RuntimeException("Plusieurs sursis actifs pour l'entretien #".$this->id, 0, null); $sursis = $item; } } return $sursis; } /** VALIDATION ****************************************************************************************************/ /** Loading module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/Mapping/EntretienProfessionnel.Entity.Db.EntretienProfessionnel.dcm.xml +1 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/Mapping/EntretienProfessionnel.Entity.Db.EntretienProfessionnel.dcm.xml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ </one-to-one> <one-to-many target-entity="EntretienProfessionnel\Entity\Db\Observation" mapped-by="entretien" field="observations"/> <one-to-many target-entity="EntretienProfessionnel\Entity\Db\Sursis" mapped-by="entretien" field="sursis"/> <!-- HISTORISATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <field name="histoCreation" type="datetime" column="histo_creation" nullable="false"/> Loading Loading
module/EntretienProfessionnel/config/merged/sursis.config.php +166 Changes for module/EntretienProfessionnel/config/merged/sursis.config.php: 166 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace EntretienProfessionnel; use EntretienProfessionnel\Controller\SursisController; use EntretienProfessionnel\Controller\SursisControllerFactory; use EntretienProfessionnel\Form\Sursis\SursisForm; use EntretienProfessionnel\Form\Sursis\SursisFormFactory; use EntretienProfessionnel\Form\Sursis\SursisHydrator; use EntretienProfessionnel\Form\Sursis\SursisHydratorFactory; use EntretienProfessionnel\Provider\Privilege\SursisPrivileges; use EntretienProfessionnel\Service\Sursis\SursisService; use EntretienProfessionnel\Service\Sursis\SursisServiceFactory; use UnicaenPrivilege\Guard\PrivilegeController; use Zend\Router\Http\Literal; use Zend\Router\Http\Segment; return [ 'bjyauthorize' => [ 'guards' => [ PrivilegeController::class => [ [ 'controller' => SursisController::class, 'action' => [ 'afficher', ], 'privileges' => [ SursisPrivileges::SURSIS_AFFICHER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'ajouter', ], 'privileges' => [ SursisPrivileges::SURSIS_AJOUTER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'modifier', ], 'privileges' => [ SursisPrivileges::SURSIS_MODIFIER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'historiser', 'restaurer', ], 'privileges' => [ SursisPrivileges::SURSIS_HISTORISER, ], ], [ 'controller' => SursisController::class, 'action' => [ 'supprimer', ], 'privileges' => [ SursisPrivileges::SURSIS_SUPPRIMER, ], ], ], ], ], 'router' => [ 'routes' => [ 'entretien-professionnel' => [ 'child_routes' => [ 'sursis' => [ 'type' => Literal::class, 'may_terminate' => false, 'options' => [ 'route' => '/sursis', ], 'child_routes' => [ 'ajouter' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/ajouter/:entretien-professionnel', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'ajouter', ], ], ], 'modifier' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/modifier/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'modifier', ], ], ], 'historiser' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/historiser/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'historiser', ], ], ], 'restaurer' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/restaurer/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'restaurer', ], ], ], 'detruire' => [ 'type' => Segment::class, 'may_terminate' => true, 'options' => [ 'route' => '/detruire/:sursis', 'defaults' => [ 'controller' => SursisController::class, 'action' => 'detruire', ], ], ], ] ], ], ], ], ], 'service_manager' => [ 'factories' => [ SursisService::class => SursisServiceFactory::class, ], ], 'controllers' => [ 'factories' => [ SursisController::class => SursisControllerFactory::class, ], ], 'form_elements' => [ 'factories' => [ SursisForm::class => SursisFormFactory::class, ], ], 'hydrators' => [ 'factories' => [ SursisHydrator::class => SursisHydratorFactory::class, ], ] ]; No newline at end of file
module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisController.php +119 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisController.php: 119 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace EntretienProfessionnel\Controller; use EntretienProfessionnel\Entity\Db\Sursis; use EntretienProfessionnel\Form\Sursis\SursisFormAwareTrait; use EntretienProfessionnel\Service\EntretienProfessionnel\EntretienProfessionnelServiceAwareTrait; use EntretienProfessionnel\Service\Sursis\SursisServiceAwareTrait; use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class SursisController extends AbstractActionController { use EntretienProfessionnelServiceAwareTrait; use SursisServiceAwareTrait; use SursisFormAwareTrait; public function afficherAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); return new ViewModel([ 'title' => "Affichage du sursis", 'sursis' => $sursis, ]); } public function ajouterAction() { $entretien = $this->getEntretienProfessionnelService()->getRequestedEntretienProfessionnel($this); $sursis = new Sursis(); $sursis->setEntretien($entretien); $form = $this->getSursisForm(); $form->setAttribute('action', $this->url()->fromRoute('sursis/ajouter', ['entretien-professionnel' => $entretien->getId()], [], true)); $form->bind($sursis); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $this->getSursisService()->create($sursis); } } $vm = new ViewModel([ 'title' => "Ajout d'un sursis", 'form' => $form, ]); $vm->setTemplate('entretien-professionnel/default/default-form'); return $vm; } public function modifierAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); $form = $this->getSursisForm(); $form->setAttribute('action', $this->url()->fromRoute('sursis/modifier', ['sursis' => $sursis->getId()], [], true)); $form->bind($sursis); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $this->getSursisService()->update($sursis); } } $vm = new ViewModel([ 'title' => "Modification d'un sursis", 'form' => $form, ]); $vm->setTemplate('entretien-professionnel/default/default-form'); return $vm; } public function historiserAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); $retour = $this->params()->fromQuery('retour'); $this->getSursisService()->historise($sursis); return $this->redirect()->toUrl($retour); } public function restaurerAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); $retour = $this->params()->fromQuery('retour'); $this->getSursisService()->restore($sursis); return $this->redirect()->toUrl($retour); } public function supprimerAction() { $sursis = $this->getSursisService()->getRequestedSursis($this); /** @var Request $request */ $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); if ($data["reponse"] === "oui") $this->getSursisService()->delete($sursis); exit(); } $vm = new ViewModel(); if ($sursis !== null) { $vm->setTemplate('entretien-professionnel/default/confirmation'); $vm->setVariables([ 'title' => "Suppression d'un sursis", 'text' => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?", 'action' => $this->url()->fromRoute('entretien-professionnel/default/supprimer', ["sursis" => $sursis->getId()], [], true), ]); } return $vm; } } No newline at end of file
module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisControllerFactory.php +32 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/SursisControllerFactory.php: 32 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace EntretienProfessionnel\Controller; use EntretienProfessionnel\Form\Sursis\SursisForm; use EntretienProfessionnel\Service\EntretienProfessionnel\EntretienProfessionnelService; use EntretienProfessionnel\Service\Sursis\SursisService; use Interop\Container\ContainerInterface; class SursisControllerFactory { public function __invoke(ContainerInterface $container) { /** * @var EntretienProfessionnelService $entretienService * @var SursisService $sursisService */ $entretienService = $container->get(EntretienProfessionnelService::class); $sursisService = $container->get(SursisService::class); /** * @var SursisForm $sursisForm */ $sursisForm = $container->get('FormElementManager')->get(SursisForm::class); $controller = new SursisController(); $controller->setEntretienProfessionnelService($entretienService); $controller->setSursisService($sursisService); $controller->setSursisForm($sursisForm); return $controller; } } No newline at end of file
module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/EntretienProfessionnel.php +20 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/EntretienProfessionnel.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ class EntretienProfessionnel implements HistoriqueAwareInterface, ResourceInterf /** @var ArrayCollection (Observation) */ private $observations; /** @var ArrayCollection (Sursis) */ private $sursis; /** @var ValidationInstance */ private $validationAgent; Loading Loading @@ -262,6 +264,24 @@ class EntretienProfessionnel implements HistoriqueAwareInterface, ResourceInterf return $observation; } /** SURSIS ********************************************************************************************************/ /** * @return Sursis|null */ public function getSursisActive() : ?Sursis { $sursis = null; /** @var Sursis $item */ foreach ($this->sursis as $item) { if ($item->estNonHistorise()) { if ($sursis !== null) throw new RuntimeException("Plusieurs sursis actifs pour l'entretien #".$this->id, 0, null); $sursis = $item; } } return $sursis; } /** VALIDATION ****************************************************************************************************/ /** Loading
module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/Mapping/EntretienProfessionnel.Entity.Db.EntretienProfessionnel.dcm.xml +1 Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Entity/Db/Mapping/EntretienProfessionnel.Entity.Db.EntretienProfessionnel.dcm.xml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ </one-to-one> <one-to-many target-entity="EntretienProfessionnel\Entity\Db\Observation" mapped-by="entretien" field="observations"/> <one-to-many target-entity="EntretienProfessionnel\Entity\Db\Sursis" mapped-by="entretien" field="sursis"/> <!-- HISTORISATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <field name="histoCreation" type="datetime" column="histo_creation" nullable="false"/> Loading