Commit 6f544418 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Retour de histo après midification de la config

parent 88983cfd
Pipeline #10744 passed with stage
in 20 seconds
......@@ -9,13 +9,11 @@ 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 *******************************************************************************************/
......
......@@ -5,7 +5,6 @@ namespace UnicaenRenderer\Service\Contenu;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use UnicaenRenderer\Service\Macro\MacroService;
use UnicaenUtilisateur\Service\User\UserService;
class ContenuServiceFactory {
......@@ -17,17 +16,14 @@ class ContenuServiceFactory {
{
/**
* @var EntityManager $entityManager
* @var UserService $userService
* @var MacroService $macroService
*/
$entityManager = $container->get('doctrine.entitymanager.orm_default');
$macroService = $container->get(MacroService::class);
$userService = $container->get(UserService::class);
$service = new ContenuService();
$service->setEntityManager($entityManager);
$service->setMacroService($macroService);
$service->setUserService($userService);
return $service;
}
}
\ No newline at end of file
......@@ -8,12 +8,10 @@ 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,15 +20,7 @@ class MacroService {
* @return Macro
*/
public function create(Macro $macro) : Macro
{
$user = $this->getUserService()->getConnectedUser();
if ($user === null) $user = $this->getUserService()->getUtilisateur(0);
$date = $this->getDateTime();
$macro->setHistoCreation($date);
$macro->setHistoCreateur($user);
$macro->setHistoModification($date);
$macro->setHistoModificateur($user);
{
try {
$this->getEntityManager()->persist($macro);
$this->getEntityManager()->flush($macro);
......@@ -46,12 +36,6 @@ class MacroService {
*/
public function update(Macro $macro) : Macro
{
$user = $this->getUserService()->getConnectedUser();
if ($user === null) $user = $this->getUserService()->getUtilisateur(0);
$date = $this->getDateTime();
$macro->setHistoModification($date);
$macro->setHistoModificateur($user);
try {
$this->getEntityManager()->flush($macro);
} catch (ORMException $e) {
......@@ -67,12 +51,7 @@ class MacroService {
public function historise(Macro $macro) : Macro
{
try {
$user = $this->getUserService()->getConnectedUser();
if ($user === null) $user = $this->getUserService()->getUtilisateur(0);
$date = $this->getDateTime();
$macro->setHistoDestruction($date);
$macro->setHistoDestructeur($user);
$macro->historiser();
$this->getEntityManager()->flush($macro);
} catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
......@@ -87,9 +66,7 @@ class MacroService {
public function restore(Macro $macro) : Macro
{
try {
$macro->setHistoDestruction(null);
$macro->setHistoDestructeur(null);
$macro->dehistoriser();
$this->getEntityManager()->flush($macro);
} catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
......
......@@ -4,7 +4,6 @@ namespace UnicaenRenderer\Service\Macro;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use UnicaenUtilisateur\Service\User\UserService;
class MacroServiceFactory {
......@@ -16,14 +15,11 @@ class MacroServiceFactory {
{
/**
* @var EntityManager $entityManager
* @var UserService $userService
*/
$entityManager = $container->get('doctrine.entitymanager.orm_default');
$userService = $container->get(UserService::class);
$service = new MacroService();
$service->setEntityManager($entityManager);
$service->setUserService($userService);
return $service;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment