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

Merge remote-tracking branch 'origin/laminas_migration_bs5'

parents 1950d9fe 412fd597
No related branches found
No related tags found
No related merge requests found
Pipeline #17742 passed
Showing
with 298 additions and 351 deletions
......@@ -8,8 +8,9 @@
}
],
"require": {
"unicaen/privilege": "^4.0",
"laminas/laminas-dependency-plugin": "^2.1"
"php": "^8.0",
"unicaen/privilege": "^5.0",
"laminas/laminas-dependency-plugin": "^2.1",
},
"autoload": {
"psr-0": [],
......
......@@ -27,8 +27,6 @@ return [
],
],
'router' => [
'routes' => [
'contenu' => [
......
......@@ -58,26 +58,6 @@ return [
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'macro' => [
'label' => 'Macros',
'route' => 'contenu/macro',
'resource' => PrivilegeController::getResourceId(MacroController::class, 'index'),
'order' => 10100,
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [
'routes' => [
'contenu' => [
......
......@@ -47,26 +47,6 @@ return [
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'rendu' => [
'label' => 'Contenus',
'route' => 'contenu/rendu',
'resource' => PrivilegeController::getResourceId(RenduController::class, 'index'),
'order' => 10300,
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [
'routes' => [
'contenu' => [
......
......@@ -66,26 +66,6 @@ return [
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'template' => [
'label' => 'Templates',
'route' => 'contenu/template',
'resource' => PrivilegeController::getResourceId(TemplateController::class, 'index'),
'order' => 10200,
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [
'routes' => [
'contenu' => [
......
......@@ -31,30 +31,6 @@ return [
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'renderer-header' => [
'label' => 'Gestion des contenus',
'route' => 'contenu',
'resources' => [
PrivilegeController::getResourceId(MacroController::class, 'index'),
PrivilegeController::getResourceId(TemplateController::class, 'index'),
PrivilegeController::getResourceId(RenduController::class, 'index'),
],
'order' => 10000,
'dropdown-header' => true,
],
],
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
__DIR__ . '/../view',
......
<?php
use UnicaenPrivilege\Guard\PrivilegeController;
use UnicaenRenderer\Controller\MacroController;
use UnicaenRenderer\Controller\RenduController;
use UnicaenRenderer\Controller\TemplateController;
return [
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'renderer-header' => [
'label' => 'Gestion des contenus',
'route' => 'contenu',
'resources' => [
PrivilegeController::getResourceId(MacroController::class, 'index'),
PrivilegeController::getResourceId(TemplateController::class, 'index'),
PrivilegeController::getResourceId(RenduController::class, 'index'),
],
'order' => 10000,
'dropdown-header' => true,
],
'pages' => [
'macro' => [
'label' => 'Macros',
'route' => 'contenu/macro',
'resource' => PrivilegeController::getResourceId(MacroController::class, 'index'),
'order' => 10100,
'icon' => 'fas fa-angle-right',
],
'template' => [
'label' => 'Templates',
'route' => 'contenu/template',
'resource' => PrivilegeController::getResourceId(TemplateController::class, 'index'),
'order' => 10200,
'icon' => 'fas fa-angle-right',
],
'rendu' => [
'label' => 'Contenus',
'route' => 'contenu/rendu',
'resource' => PrivilegeController::getResourceId(RenduController::class, 'index'),
'order' => 10300,
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
],
];
\ No newline at end of file
......@@ -27,3 +27,152 @@ Dépendances
Dépendance à **UnicaenPrivilege**
----------------------------------
1. Dans **vendor/unicaen/renderer/config/merged/index.config.php**, **vendor/unicaen/renderer/config/merged/macro.config.php**, **vendor/unicaen/renderer/config/merged/rendu.config.php**, **vendor/unicaen/renderer/config/merged/template.config.php** : `UnicaenPrivilege\Guard\PrivilegeController` pour les gardes liées aux actions.
Peut être directement remplacer par l'equivalent fournit par `unicaen/auth`.
2. Dans **vendor/unicaen/renderer/src/UnicaenRenderer/Provider/Privilege/DocumentcontenuPrivileges.php**, **vendor/unicaen/renderer/src/UnicaenRenderer/Provider/Privilege/DocumentmacroPrivileges.php**, **vendor/unicaen/renderer/src/UnicaenRenderer/Provider/Privilege/DocumenttemplatePrivileges.php** : `UnicaenPrivilege\Provider\Privilege\Privileges` classe mère des privilèges du module.
Peut être directement remplacer par l'equivalent fournit par `unicaen/auth`.
3. Utiliser UnicaenRenderer dans le cadre de UnicaenAuth, il faut écraser la config gérant les gardes de bjyauthoryze en ajoutant une config dans Application (par example `unicaen-renderer.config.php`)
```php
<?php
use UnicaenPrivilege\Guard\PrivilegeController;
use UnicaenRenderer\Controller\IndexController;
use UnicaenRenderer\Controller\MacroController;
use UnicaenRenderer\Controller\RenduController;
use UnicaenRenderer\Controller\TemplateController;
use UnicaenRenderer\Provider\Privilege\DocumentcontenuPrivileges;
use UnicaenRenderer\Provider\Privilege\DocumentmacroPrivileges;
use UnicaenRenderer\Provider\Privilege\DocumenttemplatePrivileges;
return [
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => IndexController::class,
'action' => [
'index',
],
'privileges' => [
DocumentcontenuPrivileges::DOCUMENTCONTENU_INDEX,
DocumentmacroPrivileges::DOCUMENTMACRO_INDEX,
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_INDEX
],
],
[
'controller' => MacroController::class,
'action' => [
'index',
'generer-json'
],
'privileges' => [
DocumentmacroPrivileges::DOCUMENTMACRO_INDEX,
],
],
[
'controller' => MacroController::class,
'action' => [
'ajouter',
],
'privileges' => [
DocumentmacroPrivileges::DOCUMENTMACRO_AJOUTER,
],
],
[
'controller' => MacroController::class,
'action' => [
'modifier',
],
'privileges' => [
DocumentmacroPrivileges::DOCUMENTMACRO_MODIFIER,
],
],
[
'controller' => MacroController::class,
'action' => [
'supprimer',
],
'privileges' => [
DocumentmacroPrivileges::DOCUMENTMACRO_SUPPRIMER,
],
],
[
'controller' => RenduController::class,
'action' => [
'index',
],
'privileges' => [
DocumentcontenuPrivileges::DOCUMENTCONTENU_INDEX,
],
],
[
'controller' => RenduController::class,
'action' => [
'afficher',
],
'privileges' => [
DocumentcontenuPrivileges::DOCUMENTCONTENU_AFFICHER,
],
],
[
'controller' => RenduController::class,
'action' => [
'supprimer',
],
'privileges' => [
DocumentcontenuPrivileges::DOCUMENTCONTENU_SUPPRIMER,
],
],
[
'controller' => TemplateController::class,
'action' => [
'index',
],
'privileges' => [
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_INDEX,
],
],
[
'controller' => TemplateController::class,
'action' => [
'afficher',
],
'privileges' => [
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_AFFICHER,
],
],
[
'controller' => TemplateController::class,
'action' => [
'ajouter',
],
'privileges' => [
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_AJOUTER,
],
],
[
'controller' => TemplateController::class,
'action' => [
'modifier',
],
'privileges' => [
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_MODIFIER,
],
],
[
'controller' => TemplateController::class,
'action' => [
'detruire',
],
'privileges' => [
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_SUPPRIMER,
],
],
],
],
],
];
```
......@@ -9,6 +9,6 @@ class IndexController extends AbstractActionController {
public function indexAction()
{
return new ViewModel();
return new ViewModel(['title' => 'Gestion des contenus']);
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ class MacroController extends AbstractActionController {
}
return new ViewModel([
'title' => 'Gestion des macros',
'macros' => $macros,
'variables' => $variables,
'variable' => $variable,
......
......@@ -15,6 +15,7 @@ class RenduController extends AbstractActionController {
$rendus = $this->getRenduService()->getRendus();
return new ViewModel([
'title' => 'Gestions des rendus',
'rendus' => $rendus,
]);
}
......
......@@ -20,6 +20,7 @@ class TemplateController extends AbstractActionController {
$templates = $this->getTemplateService()->getTemplates();
return new ViewModel([
'title' => 'Gestion des templates',
'templates' => $templates,
]);
}
......
......@@ -16,97 +16,55 @@ class Macro implements ResourceInterface
return self::RESOURCE_ID;
}
/** @var integer */
private $id;
/** @var string */
private $code;
/** @var string */
private $variable;
/** @var string */
private $description;
/** @var string */
private $methode;
private ?int $id = null;
private ?string $code = null;
private ?string $variable = null;
private ?string $description = null;
private ?string $methode = null;
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* @param string|null $code
* @return Macro
*/
public function setCode(?string $code) : Macro
public function setCode(?string $code): void
{
$this->code = $code;
return $this;
}
/**
* @return string
*/
public function getVariable(): ?string
{
return $this->variable;
}
/**
* @param string $variable
* @return Macro
*/
public function setVariable(string $variable) : Macro
public function setVariable(?string $variable): void
{
$this->variable = $variable;
return $this;
}
/**
* @return string
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param string|null $description
* @return Macro
*/
public function setDescription(?string $description) : Macro
public function setDescription(?string $description): void
{
$this->description = $description;
return $this;
}
/**
* @return string
*/
public function getMethode(): ?string
{
return $this->methode;
}
/**
* @param string|null $methode
* @return Macro
*/
public function setMethode(?string $methode) : Macro
public function setMethode(?string $methode): void
{
$this->methode = $methode;
return $this;
}
}
\ No newline at end of file
......@@ -17,94 +17,54 @@ class Rendu implements ResourceInterface
return self::RESOURCE_ID;
}
/** @var int */
private $id;
/** @var Template */
private $template;
/** @var DateTime */
private $date;
/** @var string */
private $sujet;
/** @var string */
private $corps;
private ?int $id = null;
private ?Template $template = null;
private ?DateTime $date = null;
private ?string $sujet = null;
private ?string $corps = null;
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return Template|null
*/
public function getTemplate(): ?Template
{
return $this->template;
}
/**
* @param Template $template
* @return Rendu
*/
public function setTemplate(Template $template): Rendu
public function setTemplate(?Template $template): void
{
$this->template = $template;
return $this;
}
/**
* @return DateTime
*/
public function getDate(): DateTime
{
return $this->date;
}
/**
* @param DateTime $date
* @return Rendu
*/
public function setDate(DateTime $date): Rendu
public function setDate(?DateTime $date): void
{
$this->date = $date;
return $this;
}
/**
* @return string
*/
public function getSujet(): string
{
return $this->sujet;
}
/**
* @param string $sujet
* @return Rendu
*/
public function setSujet(string $sujet): Rendu
public function setSujet(?string $sujet): void
{
$this->sujet = $sujet;
return $this;
}
/**
* @return string
*/
public function getCorps(): string
public function getCorps(): ?string
{
return $this->corps;
}
/**
* @param string $corps
* @return Rendu
*/
public function setCorps(string $corps): Rendu
public function setCorps(?string $corps): void
{
$this->corps = $corps;
return $this;
}
}
\ No newline at end of file
......@@ -25,145 +25,82 @@ class Template implements ResourceInterface
const TYPE_PDF = 'pdf';
const TYPE_MAIL = 'mail';
/** @var integer */
private $id;
/** @var string */
private $code;
/** @var string */
private $description;
/** @var string */
private $type;
/** @var string */
private $sujet;
/** @var string */
private $corps;
/** @var string */
private $css;
private ?int $id = null;
private ?string $code = null;
private ?string $description = null;
private ?string $type = null;
private ?string $sujet = null;
private ?string $corps = null;
private ?string $css = null;
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @param int $id
* @return Template
*/
public function setId(int $id) : Template
public function setId(int $id): void
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* @param string|null $code
* @return Template
*/
public function setCode(?string $code) : Template
public function setCode(?string $code): void
{
$this->code = $code;
return $this;
}
/**
* @return string
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param string|null $description
* @return Template
*/
public function setDescription(?string $description) : Template
public function setDescription(?string $description): void
{
$this->description = $description;
return $this;
}
/**
* @return string
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @param string|null $type
* @return Template
*/
public function setType(?string $type) : Template
public function setType(?string $type): void
{
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getSujet(): ?string
{
return $this->sujet;
}
/**
* @param string $sujet
* @return Template
*/
public function setSujet(?string $sujet): Template
public function setSujet(?string $sujet): void
{
$this->sujet = $sujet;
return $this;
}
/**
* @return string
*/
public function getCorps(): ?string
{
return $this->corps;
}
/**
* @param string $corps
* @return Template
*/
public function setCorps(?string $corps): Template
public function setCorps(?string $corps): void
{
$this->corps = $corps;
return $this;
}
/**
* @return string|null
*/
public function getCss(): ?string
{
return $this->css;
}
/**
* @param string|null $css
* @return Template
*/
public function setCss(?string $css): Template
public function setCss(?string $css): void
{
$this->css = $css;
return $this;
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
namespace UnicaenRenderer\Form\Macro;
use Doctrine\ORM\EntityManager;
use UnicaenRenderer\Entity\Db\Macro;
use DoctrineModule\Persistence\ProvidesObjectManager;
use Laminas\Form\Element\Button;
use Laminas\Form\Element\Hidden;
use Laminas\Form\Element\Text;
......@@ -11,36 +11,14 @@ use Laminas\Form\Element\Textarea;
use Laminas\Form\Form;
use Laminas\InputFilter\Factory;
use Laminas\Validator\Callback;
class MacroForm extends Form {
/**
* @var EntityManager
*/
protected $entityManager;
/**
* Spécifie le gestionnaire d'entité.
*
* @param EntityManager $entityManager
* @return self
*/
public function setEntityManager(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
return $this;
}
use UnicaenRenderer\Entity\Db\Macro;
/**
* Retourne le gestionnaire d'entité.
*
* @return EntityManager
* @property EntityManager $objectManager
*/
public function getEntityManager()
class MacroForm extends Form
{
return $this->entityManager;
}
use ProvidesObjectManager;
public function init()
{
......@@ -123,7 +101,7 @@ class MacroForm extends Form {
],
'callback' => function ($value, $context = []) {
if ($value == $context['old-code']) return true;
return ($this->getEntityManager()->getRepository(Macro::class)->findOneBy(['code'=>$value],[]) == null);
return ($this->objectManager->getRepository(Macro::class)->findOneBy(['code' => $value], []) == null);
},
//'break_chain_on_failure' => true,
],
......@@ -136,8 +114,11 @@ class MacroForm extends Form {
]));
}
public function setOldCode($value){
public function setOldCode($value)
{
$this->get('old-code')->setValue($value);
}
};
}
;
......@@ -2,28 +2,17 @@
namespace UnicaenRenderer\Form\Macro;
trait MacroFormAwareTrait {
/** @var MacroForm */
private $macroForm;
trait MacroFormAwareTrait
{
private MacroForm $macroForm;
/**
* @return MacroForm
*/
public function getMacroForm()
public function getMacroForm(): MacroForm
{
return $this->macroForm;
}
/**
* @param MacroForm $macroForm
* @return MacroForm
*/
public function setMacroForm(MacroForm $macroForm)
public function setMacroForm(MacroForm $macroForm): void
{
$this->macroForm = $macroForm;
return $this->macroForm;
}
}
\ No newline at end of file
......@@ -4,14 +4,18 @@ namespace UnicaenRenderer\Form\Macro;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class MacroFormFactory {
/**
* @param ContainerInterface $container
* @return MacroForm
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container) : MacroForm
{
/**
* @var EntityManager $entityManager
......@@ -24,7 +28,7 @@ class MacroFormFactory {
$hydrator = $container->get('HydratorManager')->get(MacroHydrator::class);
$form = new MacroForm();
$form->setEntityManager($entityManager);
$form->setObjectManager($entityManager);
$form->setHydrator($hydrator);
return $form;
}
......
......@@ -5,8 +5,8 @@ namespace UnicaenRenderer\Form\Macro;
use UnicaenRenderer\Entity\Db\Macro;
use Laminas\Hydrator\HydratorInterface;
class MacroHydrator implements HydratorInterface {
class MacroHydrator implements HydratorInterface
{
/**
* @param Macro $object
* @return array
......@@ -27,12 +27,12 @@ class MacroHydrator implements HydratorInterface {
* @param Macro $object
* @return Macro
*/
public function hydrate(array $data, $object)
public function hydrate(array $data, $object): object
{
$code = (isset($data['code']) AND trim($data['code']) !== null)?trim($data['code']):null;
$variable = (isset($data['variable']) AND trim($data['variable']) !== null)?trim($data['variable']):null;
$methode = (isset($data['methode']) AND trim($data['methode']) !== null)?trim($data['methode']):null;
$description = (isset($data['description']) AND trim($data['description']) !== null)?trim($data['description']):null;
$code = (isset($data['code']) and trim($data['code']) !== null) ? trim($data['code']) : null;
$variable = (isset($data['variable']) and trim($data['variable']) !== null) ? trim($data['variable']) : null;
$methode = (isset($data['methode']) and trim($data['methode']) !== null) ? trim($data['methode']) : null;
$description = (isset($data['description']) and trim($data['description']) !== null) ? trim($data['description']) : null;
$object->setCode($code);
$object->setVariable($variable);
......
......@@ -4,13 +4,9 @@ namespace UnicaenRenderer\Form\Macro;
use Interop\Container\ContainerInterface;
class MacroHydratorFactory {
/**
* @param ContainerInterface $container
* @return MacroHydrator
*/
public function __invoke(ContainerInterface $container)
class MacroHydratorFactory
{
public function __invoke(ContainerInterface $container): MacroHydrator
{
$hydrator = new MacroHydrator();
return $hydrator;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment