Skip to content
Snippets Groups Projects
Commit efbd0cff authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Retrait de dépendance à UnicaeApp

parent 7dfa2430
No related branches found
No related tags found
No related merge requests found
Pipeline #18060 passed
Showing
with 119 additions and 112 deletions
......@@ -8,7 +8,6 @@
}
],
"require": {
"unicaen/app": "^5",
"unicaen/privilege": "^5"
},
"autoload": {
......
......@@ -51,27 +51,7 @@ return [
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'parametre' => [
'label' => 'Paramètres',
'route' => 'parametre/index',
// 'resource' => PrivilegeController::getResourceId(CategorieController::class, 'index'),
'resource' => ParametrecategoriePrivileges::getResourceId(ParametrecategoriePrivileges::PARAMETRECATEGORIE_INDEX),
'order' => 7020,
'pages' => [],
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [
'routes' => [
......
<?php
namespace UnicaenParametre;
use UnicaenParametre\Controller\CategorieController;
use UnicaenParametre\Controller\CategorieControllerFactory;
use UnicaenParametre\Form\Categorie\CategorieForm;
use UnicaenParametre\Form\Categorie\CategorieFormFactory;
use UnicaenParametre\Form\Categorie\CategorieHydrator;
use UnicaenParametre\Form\Categorie\CategorieHydratorFactory;
use UnicaenParametre\Provider\Privilege\ParametrecategoriePrivileges;
use UnicaenParametre\Service\Categorie\CategorieService;
use UnicaenParametre\Service\Categorie\CategorieServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
return [
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'parametre' => [
'label' => 'Paramètres',
'route' => 'parametre/index',
// 'resource' => PrivilegeController::getResourceId(CategorieController::class, 'index'),
'resource' => ParametrecategoriePrivileges::getResourceId(ParametrecategoriePrivileges::PARAMETRECATEGORIE_INDEX),
'order' => 7020,
'pages' => [],
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
];
\ No newline at end of file
......@@ -91,7 +91,7 @@ class CategorieForm extends Form {
],
'attributes' => [
'type' => 'submit',
'class' => 'btn btn-default',
'class' => 'btn btn-primary',
],
]);
//input filter
......
......@@ -109,7 +109,7 @@ class ParametreForm extends Form {
],
'attributes' => [
'type' => 'submit',
'class' => 'btn btn-default',
'class' => 'btn btn-primary',
],
]);
//input filter
......
......@@ -5,13 +5,14 @@ namespace UnicaenParametre\Service\Categorie;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\QueryBuilder;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenParametre\Entity\Db\Categorie;
use DoctrineModule\Persistence\ProvidesObjectManager;
use Laminas\Mvc\Controller\AbstractActionController;
use RuntimeException;
use UnicaenParametre\Entity\Db\Categorie;
class CategorieService {
use EntityManagerAwareTrait;
class CategorieService
{
use ProvidesObjectManager;
/** GESTION ENTITY ************************************************************************************************/
......@@ -22,8 +23,8 @@ class CategorieService {
public function create(Categorie $categorie): Categorie
{
try {
$this->getEntityManager()->persist($categorie);
$this->getEntityManager()->flush($categorie);
$this->getObjectManager()->persist($categorie);
$this->getObjectManager()->flush($categorie);
} catch (ORMException $e) {
throw new RuntimeException("Une erreur s'est produite lors de l'enregistrement en base.", 0, $e);
}
......@@ -37,7 +38,7 @@ class CategorieService {
public function update(Categorie $categorie): Categorie
{
try {
$this->getEntityManager()->flush($categorie);
$this->getObjectManager()->flush($categorie);
} catch (ORMException $e) {
throw new RuntimeException("Une erreur s'est produite lors de la mise à jour en base.", 0, $e);
}
......@@ -51,8 +52,8 @@ class CategorieService {
public function delete(Categorie $categorie): Categorie
{
try {
$this->getEntityManager()->remove($categorie);
$this->getEntityManager()->flush($categorie);
$this->getObjectManager()->remove($categorie);
$this->getObjectManager()->flush($categorie);
} catch (ORMException $e) {
throw new RuntimeException("Une erreur s'est produite lors de la suppression en base.", 0, $e);
}
......@@ -66,9 +67,10 @@ class CategorieService {
*/
public function createQueryBuilder(): QueryBuilder
{
$qb = $this->getEntityManager()->getRepository(Categorie::class)->createQueryBuilder('categorie');
$qb = $this->getObjectManager()->getRepository(Categorie::class)->createQueryBuilder('categorie');
return $qb;
}
/**
* @param string $champ
* @param string $ordre
......@@ -106,8 +108,7 @@ class CategorieService {
{
$qb = $this->createQueryBuilder()
->andWhere('categorie.id = :id')
->setParameter('id', $id)
;
->setParameter('id', $id);
try {
$result = $qb->getQuery()->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
......@@ -124,8 +125,7 @@ class CategorieService {
{
$qb = $this->createQueryBuilder()
->andWhere('categorie.code = :code')
->setParameter('code', $code)
;
->setParameter('code', $code);
try {
$result = $qb->getQuery()->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
......
......@@ -4,25 +4,16 @@ namespace UnicaenParametre\Service\Categorie;
trait CategorieServiceAwareTrait {
/** @var CategorieService */
private $parametreCategorieService;
private CategorieService $parametreCategorieService;
/**
* @return CategorieService
*/
public function getCategorieService(): CategorieService
{
return $this->parametreCategorieService;
}
/**
* @param CategorieService $parametreCategorieService
* @return CategorieService
*/
public function setCategorieService(CategorieService $parametreCategorieService): CategorieService
public function setCategorieService(CategorieService $parametreCategorieService): void
{
$this->parametreCategorieService = $parametreCategorieService;
return $this->parametreCategorieService;
}
}
\ No newline at end of file
......@@ -4,14 +4,19 @@ namespace UnicaenParametre\Service\Categorie;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class CategorieServiceFactory {
class CategorieServiceFactory
{
/**
* @param ContainerInterface $container
* @return CategorieService
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): CategorieService
{
/**
* @var EntityManager $entityManager
......@@ -19,7 +24,7 @@ class CategorieServiceFactory {
$entityManager = $container->get('doctrine.entitymanager.orm_default');
$service = new CategorieService();
$service->setEntityManager($entityManager);
$service->setObjectManager($entityManager);
return $service;
}
......
......@@ -5,15 +5,15 @@ namespace UnicaenParametre\Service\Parametre;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\QueryBuilder;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
use DoctrineModule\Persistence\ProvidesObjectManager;
use RuntimeException;
use UnicaenParametre\Entity\Db\Categorie;
use UnicaenParametre\Entity\Db\Parametre;
use Laminas\Mvc\Controller\AbstractActionController;
class ParametreService
{
use EntityManagerAwareTrait;
use ProvidesObjectManager;
/** GESTION ENTITY ************************************************************************************************/
......@@ -24,8 +24,8 @@ class ParametreService
public function create(Parametre $parametre): Parametre
{
try {
$this->getEntityManager()->persist($parametre);
$this->getEntityManager()->flush($parametre);
$this->getObjectManager()->persist($parametre);
$this->getObjectManager()->flush($parametre);
} catch (ORMException $e) {
throw new RuntimeException("Une erreur s'est produite lors de l'enregistrement en base.", 0, $e);
}
......@@ -39,7 +39,7 @@ class ParametreService
public function update(Parametre $parametre): Parametre
{
try {
$this->getEntityManager()->flush($parametre);
$this->getObjectManager()->flush($parametre);
} catch (ORMException $e) {
throw new RuntimeException("Une erreur s'est produite lors de la mise à jour en base.", 0, $e);
}
......@@ -53,8 +53,8 @@ class ParametreService
public function delete(Parametre $parametre): Parametre
{
try {
$this->getEntityManager()->remove($parametre);
$this->getEntityManager()->flush($parametre);
$this->getObjectManager()->remove($parametre);
$this->getObjectManager()->flush($parametre);
} catch (ORMException $e) {
throw new RuntimeException("Une erreur s'est produite lors de la suppression en base.", 0, $e);
}
......@@ -68,7 +68,7 @@ class ParametreService
*/
public function createQueryBuilder(): QueryBuilder
{
$qb = $this->getEntityManager()->getRepository(Parametre::class)->createQueryBuilder('parametre')
$qb = $this->getObjectManager()->getRepository(Parametre::class)->createQueryBuilder('parametre')
->addSelect('categorie')->join('parametre.categorie', 'categorie');
return $qb;
}
......@@ -110,8 +110,7 @@ class ParametreService
{
$qb = $this->createQueryBuilder()
->andWhere('parametre.id = :id')
->setParameter('id', $id)
;
->setParameter('id', $id);
try {
$result = $qb->getQuery()->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
......@@ -131,8 +130,7 @@ class ParametreService
->andWhere('categorie.code = :categorieCode')
->andWhere('parametre.code = :parametreCode')
->setParameter('categorieCode', $categorieCode)
->setParameter('parametreCode', $parametreCode)
;
->setParameter('parametreCode', $parametreCode);
try {
$result = $qb->getQuery()->getOneOrNullResult();
......
......@@ -5,22 +5,13 @@ namespace UnicaenParametre\Service\Parametre;
trait ParametreServiceAwareTrait
{
/** @var ParametreService */
protected $parametreService;
protected ParametreService $parametreService;
/**
* @param ParametreService $parametreService
* @return ParametreService
*/
public function setParametreService(ParametreService $parametreService) : ParametreService
public function setParametreService(ParametreService $parametreService) : void
{
$this->parametreService = $parametreService;
return $this->parametreService;
}
/**
* @return ParametreService
*/
public function getParametreService() : ParametreService
{
return $this->parametreService;
......
......@@ -4,6 +4,8 @@ namespace UnicaenParametre\Service\Parametre;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class ParametreServiceFactory
{
......@@ -11,8 +13,10 @@ class ParametreServiceFactory
/**
* @param ContainerInterface $container
* @return ParametreService
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container) : ParametreService
{
/**
* @var EntityManager $entityManager
......@@ -20,7 +24,7 @@ class ParametreServiceFactory
$entityManager = $container->get('doctrine.entitymanager.orm_default');
$service = new ParametreService();
$service->setEntityManager($entityManager);
$service->setObjectManager($entityManager);
return $service;
}
}
\ No newline at end of file
......@@ -42,12 +42,11 @@ if ($selection !== null) $categories = [ $selection ];
<?php foreach ($categories as $categorie) : ?>
<?php $id = $categorie->getId(); ?>
<div class="row">
<h2 title="<?php echo $categorie->getDescription(); ?>" data-bs-toggle="tooltip" data-bs-html="true" style="cursor: help;"> Catégorie : <?php echo $categorie->getLibelle(); ?> </h2>
<br/>
<a <?php /** @see \Application\Controller\ParametreController::ajouterAction() */?>
href="<?php echo $this->url('parametre/ajouter', ['categorie' => $categorie->getId()], [], true); ?>"
class="btn btn-primary action ajax-modal" data-event="modification">
class="btn btn-primary ajax-modal" data-event="modification">
<i class="fas fa-plus"></i> Ajouter un paramètre
</a>
<?php if ($selection === null) : ?>
......@@ -70,7 +69,6 @@ if ($selection !== null) $categories = [ $selection ];
</span>
<?php endif; ?>
<?php endif; ?>
</div>
<br/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment