Skip to content
Snippets Groups Projects
Commit fff91df2 authored by Thibaut Vallee's avatar Thibaut Vallee
Browse files

Appel des fonctions d'update du createur/modificateur lors de la création et...

Appel des fonctions d'update du createur/modificateur lors de la création et la modification des entités
parent 19620b1b
No related branches found
No related tags found
No related merge requests found
Pipeline #10842 passed
......@@ -9,11 +9,13 @@ use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenRenderer\Entity\Db\Content;
use UnicaenRenderer\Service\Macro\MacroServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController;
class ContenuService {
use EntityManagerAwareTrait;
use MacroServiceAwareTrait;
use UserServiceAwareTrait;
/** GESTION DES ENTITES *******************************************************************************************/
......@@ -24,6 +26,7 @@ class ContenuService {
public function create(Content $content) : Content
{
try {
$content->updateCreation($this->getUserService());
$this->getEntityManager()->persist($content);
$this->getEntityManager()->flush($content);
} catch (ORMException $e) {
......@@ -39,6 +42,7 @@ class ContenuService {
public function update(Content $content) : Content
{
try {
$content->updateModification($this->getUserService());
$this->getEntityManager()->flush($content);
} catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
......
......@@ -5,6 +5,7 @@ namespace UnicaenRenderer\Service\Contenu;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use UnicaenRenderer\Service\Macro\MacroService;
use UnicaenUtilisateur\Service\User\UserService;
class ContenuServiceFactory {
......@@ -24,6 +25,11 @@ class ContenuServiceFactory {
$service = new ContenuService();
$service->setEntityManager($entityManager);
$service->setMacroService($macroService);
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$service->setUserService($userService);
return $service;
}
}
\ No newline at end of file
......@@ -8,10 +8,12 @@ use Doctrine\ORM\QueryBuilder;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenRenderer\Entity\Db\Macro;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController;
class MacroService {
use EntityManagerAwareTrait;
use UserServiceAwareTrait;
/** GESTION DES ENTITES *******************************************************************************************/
......@@ -22,6 +24,7 @@ class MacroService {
public function create(Macro $macro) : Macro
{
try {
$macro->updateCreation($this->getUserService());
$this->getEntityManager()->persist($macro);
$this->getEntityManager()->flush($macro);
} catch (ORMException $e) {
......@@ -37,6 +40,7 @@ class MacroService {
public function update(Macro $macro) : Macro
{
try {
$macro->updateModification($this->getUserService());
$this->getEntityManager()->flush($macro);
} catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
......
......@@ -4,6 +4,7 @@ namespace UnicaenRenderer\Service\Macro;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use UnicaenUtilisateur\Service\User\UserService;
class MacroServiceFactory {
......@@ -20,6 +21,10 @@ class MacroServiceFactory {
$service = new MacroService();
$service->setEntityManager($entityManager);
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$service->setUserService($userService);
return $service;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment