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

Merge remote-tracking branch 'origin/BS5' into main

parents c821563b 16d58de9
No related branches found
No related tags found
No related merge requests found
Showing
with 167 additions and 198 deletions
.idea
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
namespace UnicaenParametre; namespace UnicaenParametre;
use Zend\Config\Factory as ConfigFactory; use Laminas\Config\Factory as ConfigFactory;
use Zend\Mvc\ModuleRouteListener; use Laminas\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent; use Laminas\Mvc\MvcEvent;
use Zend\Stdlib\ArrayUtils; use Laminas\Stdlib\ArrayUtils;
use Zend\Stdlib\Glob; use Laminas\Stdlib\Glob;
class Module class Module
{ {
...@@ -35,7 +35,7 @@ class Module ...@@ -35,7 +35,7 @@ class Module
public function getAutoloaderConfig() public function getAutoloaderConfig()
{ {
return array( return array(
'Zend\Loader\StandardAutoloader' => array( 'Laminas\Loader\StandardAutoloader' => array(
'namespaces' => array( 'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
), ),
......
{ {
"name": "unicaen/parametre", "name": "unicaen/parametre",
"description": "Module de gestion de parametre", "description": "Module de gestion de paramètres",
"repositories": [ "repositories": [
{ {
"type": "composer", "type": "composer",
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
} }
], ],
"require": { "require": {
"unicaen/app": "^3.0", "unicaen/privilege": "^5"
"unicaen/privilege": "dev-master"
}, },
"autoload": { "autoload": {
"psr-0": { "psr-0": {
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
namespace UnicaenParametre; namespace UnicaenParametre;
use UnicaenPrivilege\Guard\PrivilegeController; use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal; use Laminas\Router\Http\Literal;
use Zend\Router\Http\Segment; use Laminas\Router\Http\Segment;
return [ return [
'bjyauthorize' => [ 'bjyauthorize' => [
......
...@@ -12,8 +12,8 @@ use UnicaenParametre\Provider\Privilege\ParametrecategoriePrivileges; ...@@ -12,8 +12,8 @@ use UnicaenParametre\Provider\Privilege\ParametrecategoriePrivileges;
use UnicaenParametre\Service\Categorie\CategorieService; use UnicaenParametre\Service\Categorie\CategorieService;
use UnicaenParametre\Service\Categorie\CategorieServiceFactory; use UnicaenParametre\Service\Categorie\CategorieServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController; use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal; use Laminas\Router\Http\Literal;
use Zend\Router\Http\Segment; use Laminas\Router\Http\Segment;
return [ return [
'bjyauthorize' => [ 'bjyauthorize' => [
...@@ -51,27 +51,7 @@ return [ ...@@ -51,27 +51,7 @@ return [
], ],
], ],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'parametre' => [
'label' => 'Paramètres',
'route' => 'parametre/index',
// 'resource' => PrivilegeController::getResourceId(CategorieController::class, 'index'),
'resource' => ParametrecategoriePrivileges::getResourceId(ParametrecategoriePrivileges::PARAMETRECATEGORIE_INDEX),
'order' => 7020,
'pages' => [],
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [ 'router' => [
'routes' => [ 'routes' => [
......
...@@ -10,8 +10,8 @@ use UnicaenParametre\Provider\Privilege\ParametrePrivileges; ...@@ -10,8 +10,8 @@ use UnicaenParametre\Provider\Privilege\ParametrePrivileges;
use UnicaenParametre\Service\Parametre\ParametreService; use UnicaenParametre\Service\Parametre\ParametreService;
use UnicaenParametre\Service\Parametre\ParametreServiceFactory; use UnicaenParametre\Service\Parametre\ParametreServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController; use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal; use Laminas\Router\Http\Literal;
use Zend\Router\Http\Segment; use Laminas\Router\Http\Segment;
return [ return [
'bjyauthorize' => [ 'bjyauthorize' => [
......
<?php
namespace UnicaenParametre;
use UnicaenParametre\Provider\Privilege\ParametrecategoriePrivileges;
return [
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'parametre' => [
'label' => 'Paramètres',
'route' => 'parametre/index',
// 'resource' => PrivilegeController::getResourceId(CategorieController::class, 'index'),
'resource' => ParametrecategoriePrivileges::getResourceId(ParametrecategoriePrivileges::PARAMETRECATEGORIE_INDEX),
'order' => 7020,
'pages' => [],
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
];
\ No newline at end of file
UnicaenParametre UnicaenParametre
============ ============
UnicaenParametre est une biltiothèque de gestion de catégories de paramètre et de paramètres. UnicaenParametre est une bibliothèque de gestion de paramètres.
Les paramètres sont désignés par une catégorie et un code.
Route d'accès Le module fournit un menu d'administration permettant la déclaration des paramètres et de leur catégorie,
------------- ainsi que l'affectation de leur valeur.
- */parametre/index* donne accès aux paramètres de toutes les catégories
- */parametre/index/categorieId* donne accès aux paramètres de la catégorie *categorieId*
Récupération de la valeur d'un paramètre Récupération de la valeur d'un paramètre
---------------------------------------- ----------------------------------------
```php ```php
$this->getParametreService()->getParametreByCode('ma_categorie','mon_parametre')->getValeur(); $this->getParametreService()->getValeurForParametre('ma_categorie','mon_parametre');
``` ```
**N.B.:** Il n'y a pas d'historisation des paramètres ou de leur catégorie. Est-ce bien nécessaire ? Si le paramètre n'est pas trouvé alors une exception ```ParametreNotFoundException``` est lancée.
Si le paramètre n'est pas typé correctement alors une exception ```ParametreMalTypeException``` est lancée.
***TODO*** À propos du typage :
- Étendre le typage
- Modifier le formulaire pour exploiter les types "déclarés"
Bonnes pratiques
----------------
Afin de mieux référencer les catégories et les paramètres, il est recommandé de mettre en place un provider de parametres déclarant en constante : la catégorie et les paramètres.
```php
<?php
namespace Formation\Provider\Parametre;
class FormationParametres {
const CATEGORIE = 'FORMATION';
const NB_PLACE_PRINCIPALE = 'NB_PLACE_PRINCIPALE';
const NB_PLACE_COMPLEMENTAIRE = 'NB_PLACE_COMPLEMENTAIRE';
}
```
- - - - - - - - - - - - - - - - - - - - - - - - - -
Installation Installation
============ ============
Dans le répertoire **doc** du module, on retrouve le fichier *database.sql* qui permet de construire la table associée au Dans le répertoire **doc** du module, on retrouve le fichier *database.sql* qui permet de construire la table associée au
module et d'ajouter les privilèges associés. module et d'ajouter les privilèges associés.
Le module s'attend à avoir un menu **Administration** pour mettre un menu secondaire **Paramètres**. La navigation est fourni par le fichier ```unicaen-parametre.global.php(.dist)``` et doit être adaptée à votre application.
Pensez à l'ajouter s'il n'existe pas ou à modifier la naviguation dans *categorie.config.php*.
- - - - - - - - - - - - - - - - - - - - - - - - - -
Historique
ChangeLog
========== ==========
version 0.1.0 25/02/2021 **5.0.1**
------------------------ - Ajout de la fonction de la valeur dans le service ParametreService
Version initiale du module. - Ajout de l'exception ```ParametreNotFoundException```
- Transformation des classes des entités *à la PHP8*
**5.0.0**
- Finalisation de la migration à BootStrap 5.
Améliorations possibles Améliorations possibles
----------------------- -----------------------
......
...@@ -6,15 +6,15 @@ use UnicaenParametre\Entity\Db\Categorie; ...@@ -6,15 +6,15 @@ use UnicaenParametre\Entity\Db\Categorie;
use UnicaenParametre\Form\Categorie\CategorieFormAwareTrait; use UnicaenParametre\Form\Categorie\CategorieFormAwareTrait;
use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait; use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait;
use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait; use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController; use Laminas\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel; use Laminas\View\Model\ViewModel;
class CategorieController extends AbstractActionController { class CategorieController extends AbstractActionController {
use CategorieServiceAwareTrait; use CategorieServiceAwareTrait;
use ParametreServiceAwareTrait; use ParametreServiceAwareTrait;
use CategorieFormAwareTrait; use CategorieFormAwareTrait;
public function indexAction() public function indexAction() : ViewModel
{ {
$categories = $this->getCategorieService()->getCategories(); $categories = $this->getCategorieService()->getCategories();
$parametres = $this->getParametreService()->getParametres(); $parametres = $this->getParametreService()->getParametres();
...@@ -27,7 +27,8 @@ class CategorieController extends AbstractActionController { ...@@ -27,7 +27,8 @@ class CategorieController extends AbstractActionController {
]); ]);
} }
public function ajouterAction() { public function ajouterAction() : ViewModel
{
$categorie = new Categorie(); $categorie = new Categorie();
$form = $this->getCategorieForm(); $form = $this->getCategorieForm();
...@@ -51,7 +52,7 @@ class CategorieController extends AbstractActionController { ...@@ -51,7 +52,7 @@ class CategorieController extends AbstractActionController {
return $vm; return $vm;
} }
public function modifierAction() public function modifierAction() : ViewModel
{ {
$categorie = $this->getCategorieService()->getRequestedCategorie($this); $categorie = $this->getCategorieService()->getRequestedCategorie($this);
$form = $this->getCategorieForm(); $form = $this->getCategorieForm();
...@@ -76,7 +77,7 @@ class CategorieController extends AbstractActionController { ...@@ -76,7 +77,7 @@ class CategorieController extends AbstractActionController {
return $vm; return $vm;
} }
public function supprimerAction() public function supprimerAction() : ViewModel
{ {
$categorie = $this->getCategorieService()->getRequestedCategorie($this); $categorie = $this->getCategorieService()->getRequestedCategorie($this);
......
...@@ -3,13 +3,21 @@ ...@@ -3,13 +3,21 @@
namespace UnicaenParametre\Controller; namespace UnicaenParametre\Controller;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenParametre\Form\Categorie\CategorieForm; use UnicaenParametre\Form\Categorie\CategorieForm;
use UnicaenParametre\Service\Categorie\CategorieService; use UnicaenParametre\Service\Categorie\CategorieService;
use UnicaenParametre\Service\Parametre\ParametreService; use UnicaenParametre\Service\Parametre\ParametreService;
class CategorieControllerFactory { class CategorieControllerFactory {
public function __invoke(ContainerInterface $container) /**
* @param ContainerInterface $container
* @return CategorieController
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container) : CategorieController
{ {
/** /**
* @var CategorieService $categorieService * @var CategorieService $categorieService
......
...@@ -6,15 +6,15 @@ use UnicaenParametre\Entity\Db\Parametre; ...@@ -6,15 +6,15 @@ use UnicaenParametre\Entity\Db\Parametre;
use UnicaenParametre\Form\Parametre\ParametreFormAwareTrait; use UnicaenParametre\Form\Parametre\ParametreFormAwareTrait;
use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait; use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait;
use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait; use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController; use Laminas\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel; use Laminas\View\Model\ViewModel;
class ParametreController extends AbstractActionController { class ParametreController extends AbstractActionController {
use CategorieServiceAwareTrait; use CategorieServiceAwareTrait;
use ParametreServiceAwareTrait; use ParametreServiceAwareTrait;
use ParametreFormAwareTrait; use ParametreFormAwareTrait;
public function ajouterAction() public function ajouterAction() : ViewModel
{ {
$categorie = $this->getCategorieService()->getRequestedCategorie($this); $categorie = $this->getCategorieService()->getRequestedCategorie($this);
$parametre = new Parametre(); $parametre = new Parametre();
...@@ -41,7 +41,7 @@ class ParametreController extends AbstractActionController { ...@@ -41,7 +41,7 @@ class ParametreController extends AbstractActionController {
return $vm; return $vm;
} }
public function modifierAction() public function modifierAction() : ViewModel
{ {
$parametre = $this->getParametreService()->getRequestedParametre($this); $parametre = $this->getParametreService()->getRequestedParametre($this);
$form = $this->getParametreForm(); $form = $this->getParametreForm();
...@@ -67,7 +67,7 @@ class ParametreController extends AbstractActionController { ...@@ -67,7 +67,7 @@ class ParametreController extends AbstractActionController {
return $vm; return $vm;
} }
public function supprimerAction() public function supprimerAction() : ViewModel
{ {
$parametre = $this->getParametreService()->getRequestedParametre($this); $parametre = $this->getParametreService()->getRequestedParametre($this);
...@@ -90,7 +90,7 @@ class ParametreController extends AbstractActionController { ...@@ -90,7 +90,7 @@ class ParametreController extends AbstractActionController {
return $vm; return $vm;
} }
public function modifierValeurAction() public function modifierValeurAction() : ViewModel
{ {
$parametre = $this->getParametreService()->getRequestedParametre($this); $parametre = $this->getParametreService()->getRequestedParametre($this);
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace UnicaenParametre\Controller; namespace UnicaenParametre\Controller;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenParametre\Form\Parametre\ParametreForm; use UnicaenParametre\Form\Parametre\ParametreForm;
use UnicaenParametre\Service\Categorie\CategorieService; use UnicaenParametre\Service\Categorie\CategorieService;
use UnicaenParametre\Service\Parametre\ParametreService; use UnicaenParametre\Service\Parametre\ParametreService;
...@@ -12,8 +14,10 @@ class ParametreControllerFactory { ...@@ -12,8 +14,10 @@ class ParametreControllerFactory {
/** /**
* @param ContainerInterface $container * @param ContainerInterface $container
* @return ParametreController * @return ParametreController
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/ */
public function __invoke(ContainerInterface $container) public function __invoke(ContainerInterface $container) : ParametreController
{ {
/** /**
* @var CategorieService $categorieService * @var CategorieService $categorieService
......
...@@ -6,91 +6,55 @@ class Categorie ...@@ -6,91 +6,55 @@ class Categorie
{ {
const DEFAULT_ORDER = 9999; const DEFAULT_ORDER = 9999;
/** @var integer */ private ?int $id = null;
private $id; private ?string $code = null;
/** @var string */ private ?string $libelle = null;
private $code; private ?string $description = null;
/** @var string */ private ?int $ordre = null;
private $libelle;
/** @var string */
private $description;
/** @var integer */
private $ordre;
/**
* @return int
*/
public function getId(): int public function getId(): int
{ {
return $this->id; return $this->id;
} }
/**
* @return string|null
*/
public function getCode(): ?string public function getCode(): ?string
{ {
return $this->code; return $this->code;
} }
/**
* @param string|null $code
* @return Categorie
*/
public function setCode(?string $code): Categorie public function setCode(?string $code): Categorie
{ {
$this->code = $code; $this->code = $code;
return $this; return $this;
} }
/**
* @return string|null
*/
public function getLibelle(): ?string public function getLibelle(): ?string
{ {
return $this->libelle; return $this->libelle;
} }
/**
* @param string|null $libelle
* @return Categorie
*/
public function setLibelle(?string $libelle): Categorie public function setLibelle(?string $libelle): Categorie
{ {
$this->libelle = $libelle; $this->libelle = $libelle;
return $this; return $this;
} }
/**
* @return string|null
*/
public function getDescription(): ?string public function getDescription(): ?string
{ {
return $this->description; return $this->description;
} }
/**
* @param string|null $description
* @return Categorie
*/
public function setDescription(?string $description): Categorie public function setDescription(?string $description): Categorie
{ {
$this->description = $description; $this->description = $description;
return $this; return $this;
} }
/**
* @return int|null
*/
public function getOrdre(): ?int public function getOrdre(): ?int
{ {
return $this->ordre; return $this->ordre;
} }
/**
* @param int $ordre
* @return Categorie
*/
public function setOrdre(int $ordre = Categorie::DEFAULT_ORDER): Categorie public function setOrdre(int $ordre = Categorie::DEFAULT_ORDER): Categorie
{ {
$this->ordre = $ordre; $this->ordre = $ordre;
......
...@@ -6,151 +6,95 @@ class Parametre ...@@ -6,151 +6,95 @@ class Parametre
{ {
const DEFAULT_ORDER = 9999; const DEFAULT_ORDER = 9999;
/** @var integer */ const TYPE_STRING = "String";
private $id; const TYPE_BOOLEAN = "Boolean";
/** @var Categorie */ const TYPE_NUMBER = "Number";
private $categorie;
/** @var string */ private ?int $id = null;
private $code; private ?Categorie $categorie = null;
/** @var string */ private ?string $code = null;
private $libelle; private ?string $libelle = null;
/** @var string */ private ?string $description = null;
private $description; private ?string $valeur = null;
/** @var string */ private ?string $valeurs_possibles = null;
private $valeur; private ?int $ordre = null;
/** @var string */
private $valeurs_possibles;
/** @var integer */
private $ordre;
/**
* @return int
*/
public function getId(): int public function getId(): int
{ {
return $this->id; return $this->id;
} }
/**
* @return Categorie|null
*/
public function getCategorie(): ?Categorie public function getCategorie(): ?Categorie
{ {
return $this->categorie; return $this->categorie;
} }
/**
* @param Categorie|null $categorie
* @return Parametre
*/
public function setCategorie(?Categorie $categorie): Parametre public function setCategorie(?Categorie $categorie): Parametre
{ {
$this->categorie = $categorie; $this->categorie = $categorie;
return $this; return $this;
} }
/**
* @return string|null
*/
public function getCode(): ?string public function getCode(): ?string
{ {
return $this->code; return $this->code;
} }
/**
* @param string|null $code
* @return Parametre
*/
public function setCode(?string $code): Parametre public function setCode(?string $code): Parametre
{ {
$this->code = $code; $this->code = $code;
return $this; return $this;
} }
/**
* @return string|null
*/
public function getLibelle(): ?string public function getLibelle(): ?string
{ {
return $this->libelle; return $this->libelle;
} }
/**
* @param string|null $libelle
* @return Parametre
*/
public function setLibelle(?string $libelle): Parametre public function setLibelle(?string $libelle): Parametre
{ {
$this->libelle = $libelle; $this->libelle = $libelle;
return $this; return $this;
} }
/**
* @return string|null
*/
public function getDescription(): ?string public function getDescription(): ?string
{ {
return $this->description; return $this->description;
} }
/**
* @param string|null $description
* @return Parametre
*/
public function setDescription(?string $description): Parametre public function setDescription(?string $description): Parametre
{ {
$this->description = $description; $this->description = $description;
return $this; return $this;
} }
/**
* @return string|null
*/
public function getValeur(): ?string public function getValeur(): ?string
{ {
return $this->valeur; return $this->valeur;
} }
/**
* @param string|null $valeur
* @return Parametre
*/
public function setValeur(?string $valeur): Parametre public function setValeur(?string $valeur): Parametre
{ {
$this->valeur = $valeur; $this->valeur = $valeur;
return $this; return $this;
} }
/**
* @return string|null
*/
public function getValeursPossibles(): ?string public function getValeursPossibles(): ?string
{ {
return $this->valeurs_possibles; return $this->valeurs_possibles;
} }
/**
* @param string|null $valeurs_possibles
* @return Parametre
*/
public function setValeursPossibles(?string $valeurs_possibles): Parametre public function setValeursPossibles(?string $valeurs_possibles): Parametre
{ {
$this->valeurs_possibles = $valeurs_possibles; $this->valeurs_possibles = $valeurs_possibles;
return $this; return $this;
} }
/**
* @return int|null
*/
public function getOrdre(): ?int public function getOrdre(): ?int
{ {
return $this->ordre; return $this->ordre;
} }
/**
* @param int $ordre
* @return Parametre
*/
public function setOrdre(int $ordre = Parametre::DEFAULT_ORDER): Parametre public function setOrdre(int $ordre = Parametre::DEFAULT_ORDER): Parametre
{ {
$this->ordre = $ordre; $this->ordre = $ordre;
......
<?php
namespace parametre\src\UnicaenParametre\Exception;
use Exception;
class ParametreMalTypeException extends Exception {}
\ No newline at end of file
<?php
namespace UnicaenParametre\Exception;
use Exception;
class ParametreNotFoundException extends Exception {}
\ No newline at end of file
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
namespace UnicaenParametre\Form\Categorie; namespace UnicaenParametre\Form\Categorie;
use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait; use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait;
use Zend\Form\Element\Button; use Laminas\Form\Element\Button;
use Zend\Form\Element\Hidden; use Laminas\Form\Element\Hidden;
use Zend\Form\Element\Number; use Laminas\Form\Element\Number;
use Zend\Form\Element\Text; use Laminas\Form\Element\Text;
use Zend\Form\Element\Textarea; use Laminas\Form\Element\Textarea;
use Zend\Form\Form; use Laminas\Form\Form;
use Zend\InputFilter\Factory; use Laminas\InputFilter\Factory;
use Zend\Validator\Callback; use Laminas\Validator\Callback;
class CategorieForm extends Form { class CategorieForm extends Form {
use CategorieServiceAwareTrait; use CategorieServiceAwareTrait;
...@@ -91,7 +91,7 @@ class CategorieForm extends Form { ...@@ -91,7 +91,7 @@ class CategorieForm extends Form {
], ],
'attributes' => [ 'attributes' => [
'type' => 'submit', 'type' => 'submit',
'class' => 'btn btn-default', 'class' => 'btn btn-primary',
], ],
]); ]);
//input filter //input filter
......
...@@ -4,24 +4,15 @@ namespace UnicaenParametre\Form\Categorie; ...@@ -4,24 +4,15 @@ namespace UnicaenParametre\Form\Categorie;
trait CategorieFormAwareTrait { trait CategorieFormAwareTrait {
/** @var CategorieForm */ private CategorieForm $categorieForm;
private $categorieForm;
/**
* @return CategorieForm
*/
public function getCategorieForm(): CategorieForm public function getCategorieForm(): CategorieForm
{ {
return $this->categorieForm; return $this->categorieForm;
} }
/** public function setCategorieForm(CategorieForm $categorieForm): void
* @param CategorieForm $categorieForm
* @return CategorieForm
*/
public function setCategorieForm(CategorieForm $categorieForm): CategorieForm
{ {
$this->categorieForm = $categorieForm; $this->categorieForm = $categorieForm;
return $this->categorieForm;
} }
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace UnicaenParametre\Form\Categorie; namespace UnicaenParametre\Form\Categorie;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenParametre\Service\Categorie\CategorieService; use UnicaenParametre\Service\Categorie\CategorieService;
class CategorieFormFactory { class CategorieFormFactory {
...@@ -10,8 +12,10 @@ class CategorieFormFactory { ...@@ -10,8 +12,10 @@ class CategorieFormFactory {
/** /**
* @param ContainerInterface $container * @param ContainerInterface $container
* @return CategorieForm * @return CategorieForm
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/ */
public function __invoke(ContainerInterface $container) public function __invoke(ContainerInterface $container) : CategorieForm
{ {
/** /**
* @var CategorieService $categorieService * @var CategorieService $categorieService
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace UnicaenParametre\Form\Categorie; namespace UnicaenParametre\Form\Categorie;
use UnicaenParametre\Entity\Db\Categorie; use UnicaenParametre\Entity\Db\Categorie;
use Zend\Hydrator\HydratorInterface; use Laminas\Hydrator\HydratorInterface;
class CategorieHydrator implements HydratorInterface { class CategorieHydrator implements HydratorInterface {
...@@ -11,7 +11,7 @@ class CategorieHydrator implements HydratorInterface { ...@@ -11,7 +11,7 @@ class CategorieHydrator implements HydratorInterface {
* @param Categorie $object * @param Categorie $object
* @return array|void * @return array|void
*/ */
public function extract($object) public function extract(object $object) : array
{ {
$data = [ $data = [
'code' => $object->getCode(), 'code' => $object->getCode(),
...@@ -27,7 +27,7 @@ class CategorieHydrator implements HydratorInterface { ...@@ -27,7 +27,7 @@ class CategorieHydrator implements HydratorInterface {
* @param Categorie $object * @param Categorie $object
* @return Categorie * @return Categorie
*/ */
public function hydrate(array $data, $object) public function hydrate(array $data, $object) : object
{ {
$code = (isset($data['code']) and trim($data['code']) !== '')?trim($data['code']):null; $code = (isset($data['code']) and trim($data['code']) !== '')?trim($data['code']):null;
$libelle = (isset($data['libelle']) and trim($data['libelle']) !== '')?trim($data['libelle']):null; $libelle = (isset($data['libelle']) and trim($data['libelle']) !== '')?trim($data['libelle']):null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment