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;
use UnicaenUtilisateur\Entity\HistoriqueAwareInterface;
use UnicaenUtilisateur\Entity\HistoriqueAwareTrait;
use Zend\Permissions\Acl\Resource\ResourceInterface;
class Macro implements HistoriqueAwareInterface {
class Macro implements HistoriqueAwareInterface , ResourceInterface
{
use HistoriqueAwareTrait;
const RESOURCE_ID = 'Macro';
/**
* Returns the string identifier of the Resource
*
* @return string
*/
public function getResourceId()
{
return self::RESOURCE_ID;
}
/** @var integer */
private $id;
/** @var string */
......
......@@ -4,10 +4,23 @@ namespace UnicaenRenderer\Entity\Db;
use UnicaenUtilisateur\Entity\HistoriqueAwareInterface;
use UnicaenUtilisateur\Entity\HistoriqueAwareTrait;
use Zend\Permissions\Acl\Resource\ResourceInterface;
class Template implements HistoriqueAwareInterface {
class Template implements HistoriqueAwareInterface, ResourceInterface
{
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_PDF = 'pdf';
const TYPE_MAIL = 'mail';
......
......@@ -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
......@@ -9,11 +9,13 @@ use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenRenderer\Entity\Db\Template;
use UnicaenRenderer\Service\Macro\MacroServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController;
class TemplateService {
use EntityManagerAwareTrait;
use MacroServiceAwareTrait;
use UserServiceAwareTrait;
/** GESTION DES ENTITES *******************************************************************************************/
......@@ -24,8 +26,8 @@ class TemplateService {
public function create(Template $template) : Template
{
try {
$this->getEntityManager()->persist($template);
$this->getEntityManager()->flush($template);
$this->getEntityManager()->persist($content);
$this->getEntityManager()->flush($content);
} catch (ORMException $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;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use UnicaenRenderer\Service\Macro\MacroService;
use UnicaenUtilisateur\Service\User\UserService;
class TemplateServiceFactory {
......@@ -24,6 +25,11 @@ class TemplateServiceFactory {
$service = new TemplateService();
$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
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