Commit 7348049b authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Merging

parents c01bfd09 fff91df2
Pipeline #11015 passed with stage
in 35 seconds
...@@ -4,10 +4,23 @@ namespace UnicaenRenderer\Entity\Db; ...@@ -4,10 +4,23 @@ namespace UnicaenRenderer\Entity\Db;
use UnicaenUtilisateur\Entity\HistoriqueAwareInterface; use UnicaenUtilisateur\Entity\HistoriqueAwareInterface;
use UnicaenUtilisateur\Entity\HistoriqueAwareTrait; use UnicaenUtilisateur\Entity\HistoriqueAwareTrait;
use Zend\Permissions\Acl\Resource\ResourceInterface;
class Macro implements HistoriqueAwareInterface { class Macro implements HistoriqueAwareInterface , ResourceInterface
{
use HistoriqueAwareTrait; use HistoriqueAwareTrait;
const RESOURCE_ID = 'Macro';
/**
* Returns the string identifier of the Resource
*
* @return string
*/
public function getResourceId()
{
return self::RESOURCE_ID;
}
/** @var integer */ /** @var integer */
private $id; private $id;
/** @var string */ /** @var string */
......
...@@ -4,10 +4,23 @@ namespace UnicaenRenderer\Entity\Db; ...@@ -4,10 +4,23 @@ namespace UnicaenRenderer\Entity\Db;
use UnicaenUtilisateur\Entity\HistoriqueAwareInterface; use UnicaenUtilisateur\Entity\HistoriqueAwareInterface;
use UnicaenUtilisateur\Entity\HistoriqueAwareTrait; use UnicaenUtilisateur\Entity\HistoriqueAwareTrait;
use Zend\Permissions\Acl\Resource\ResourceInterface;
class Template implements HistoriqueAwareInterface { class Template implements HistoriqueAwareInterface, ResourceInterface
{
use HistoriqueAwareTrait; use HistoriqueAwareTrait;
const RESOURCE_ID = 'Template';
/**
* Returns the string identifier of the Resource
*
* @return string
*/
public function getResourceId()
{
return self::RESOURCE_ID;
}
const TYPE_TXT = 'texte'; const TYPE_TXT = 'texte';
const TYPE_PDF = 'pdf'; const TYPE_PDF = 'pdf';
const TYPE_MAIL = 'mail'; const TYPE_MAIL = 'mail';
......
...@@ -8,10 +8,12 @@ use Doctrine\ORM\QueryBuilder; ...@@ -8,10 +8,12 @@ use Doctrine\ORM\QueryBuilder;
use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait; use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenRenderer\Entity\Db\Macro; use UnicaenRenderer\Entity\Db\Macro;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController; use Zend\Mvc\Controller\AbstractActionController;
class MacroService { class MacroService {
use EntityManagerAwareTrait; use EntityManagerAwareTrait;
use UserServiceAwareTrait;
/** GESTION DES ENTITES *******************************************************************************************/ /** GESTION DES ENTITES *******************************************************************************************/
...@@ -22,6 +24,7 @@ class MacroService { ...@@ -22,6 +24,7 @@ class MacroService {
public function create(Macro $macro) : Macro public function create(Macro $macro) : Macro
{ {
try { try {
$macro->updateCreation($this->getUserService());
$this->getEntityManager()->persist($macro); $this->getEntityManager()->persist($macro);
$this->getEntityManager()->flush($macro); $this->getEntityManager()->flush($macro);
} catch (ORMException $e) { } catch (ORMException $e) {
...@@ -37,6 +40,7 @@ class MacroService { ...@@ -37,6 +40,7 @@ class MacroService {
public function update(Macro $macro) : Macro public function update(Macro $macro) : Macro
{ {
try { try {
$macro->updateModification($this->getUserService());
$this->getEntityManager()->flush($macro); $this->getEntityManager()->flush($macro);
} catch (ORMException $e) { } catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e); throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
......
...@@ -4,6 +4,7 @@ namespace UnicaenRenderer\Service\Macro; ...@@ -4,6 +4,7 @@ namespace UnicaenRenderer\Service\Macro;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use UnicaenUtilisateur\Service\User\UserService;
class MacroServiceFactory { class MacroServiceFactory {
...@@ -20,6 +21,10 @@ class MacroServiceFactory { ...@@ -20,6 +21,10 @@ class MacroServiceFactory {
$service = new MacroService(); $service = new MacroService();
$service->setEntityManager($entityManager); $service->setEntityManager($entityManager);
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$service->setUserService($userService);
return $service; return $service;
} }
} }
\ No newline at end of file
...@@ -9,11 +9,13 @@ use UnicaenApp\Exception\RuntimeException; ...@@ -9,11 +9,13 @@ use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait; use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenRenderer\Entity\Db\Template; use UnicaenRenderer\Entity\Db\Template;
use UnicaenRenderer\Service\Macro\MacroServiceAwareTrait; use UnicaenRenderer\Service\Macro\MacroServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController; use Zend\Mvc\Controller\AbstractActionController;
class TemplateService { class TemplateService {
use EntityManagerAwareTrait; use EntityManagerAwareTrait;
use MacroServiceAwareTrait; use MacroServiceAwareTrait;
use UserServiceAwareTrait;
/** GESTION DES ENTITES *******************************************************************************************/ /** GESTION DES ENTITES *******************************************************************************************/
...@@ -24,8 +26,8 @@ class TemplateService { ...@@ -24,8 +26,8 @@ class TemplateService {
public function create(Template $template) : Template public function create(Template $template) : Template
{ {
try { try {
$this->getEntityManager()->persist($template); $this->getEntityManager()->persist($content);
$this->getEntityManager()->flush($template); $this->getEntityManager()->flush($content);
} catch (ORMException $e) { } catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD du Template.", $e); throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD du Template.", $e);
} }
......
...@@ -5,6 +5,7 @@ namespace UnicaenRenderer\Service\Template; ...@@ -5,6 +5,7 @@ namespace UnicaenRenderer\Service\Template;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use UnicaenRenderer\Service\Macro\MacroService; use UnicaenRenderer\Service\Macro\MacroService;
use UnicaenUtilisateur\Service\User\UserService;
class TemplateServiceFactory { class TemplateServiceFactory {
...@@ -24,6 +25,11 @@ class TemplateServiceFactory { ...@@ -24,6 +25,11 @@ class TemplateServiceFactory {
$service = new TemplateService(); $service = new TemplateService();
$service->setEntityManager($entityManager); $service->setEntityManager($entityManager);
$service->setMacroService($macroService); $service->setMacroService($macroService);
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$service->setUserService($userService);
return $service; return $service;
} }
} }
\ No newline at end of file
Supports Markdown
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