Loading config/merged/indicateur.config.php +11 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ use UnicaenIndicateur\Form\Indicateur\IndicateurHydratorFactory; use UnicaenIndicateur\Provider\Privilege\IndicateurPrivileges; use UnicaenIndicateur\Service\Indicateur\IndicateurService; use UnicaenIndicateur\Service\Indicateur\IndicateurServiceFactory; use UnicaenIndicateur\View\Helper\DefaultItemViewHelper; use UnicaenIndicateur\View\Helper\IndicateurViewHelperFactory; use UnicaenPrivilege\Guard\PrivilegeController; use Laminas\Mvc\Console\Router\Simple; use Laminas\Router\Http\Literal; Loading Loading @@ -200,6 +202,13 @@ return [ 'factories' => [ IndicateurHydrator::class => IndicateurHydratorFactory::class, ], ] ], 'view_helpers' => [ 'invokables' => [ 'defaultItem' => DefaultItemViewHelper::class, ], 'factories' => [ 'indicateur' => IndicateurViewHelperFactory::class, ], ], ]; No newline at end of file src/UnicaenIndicateur/View/Helper/DefaultItemViewHelper.php 0 → 100644 +36 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; use Laminas\View\Helper\AbstractHelper; class DefaultItemViewHelper extends AbstractHelper implements ItemViewHelperInterface { public function getHeader(array $data) : string { $headers = $data[0]; $texte = "<thead>"; $texte .= "<tr>"; foreach ($headers as $header) { $texte .= "<th>"; $texte .= $header; $texte .= "</th>"; } $texte .= "</tr>"; $texte .= "</thead>"; return $texte; } public function getItem(array $data, int $position) : string { $values = $data[1][$position]; $texte = "<tr>"; foreach ($values as $value) { $texte .= "<td>"; $texte .= $value; $texte .= "</td>"; } $texte .= "</tr>"; return $texte; } } No newline at end of file src/UnicaenIndicateur/View/Helper/IndicateurViewHelper.php 0 → 100644 +31 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; use Laminas\View\Helper\AbstractHelper; use Laminas\View\Renderer\PhpRenderer; use Laminas\View\Resolver\TemplatePathStack; use UnicaenIndicateur\Entity\Db\Indicateur; use UnicaenIndicateur\Service\Indicateur\IndicateurServiceAwareTrait; class IndicateurViewHelper extends AbstractHelper { use IndicateurServiceAwareTrait; /** * @param Indicateur $indicateur * @param array $options * @return \Laminas\View\Helper\Partial|string * * La clef $options['ViewHelper'] permet d'indiquer le ViewHelperpour réaliser l'affichage * attention celui-ci doit implementer l'interface ItemViewHelperInterface */ public function __invoke(Indicateur $indicateur, array $options = []) { /** @var PhpRenderer $view */ $view = $this->getView(); $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]])); $data = $this->getIndicateurService()->getIndicateurData($indicateur); return $view->partial('indicateur', ['indicateur' => $indicateur, 'data' => $data, 'options' => $options]); } } No newline at end of file src/UnicaenIndicateur/View/Helper/IndicateurViewHelperFactory.php 0 → 100644 +29 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; use UnicaenIndicateur\Service\Indicateur\IndicateurService; class IndicateurViewHelperFactory { /** * @param ContainerInterface $container * @return IndicateurViewHelper * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container) : IndicateurViewHelper { /** * @var IndicateurService $indicateurService */ $indicateurService = $container->get(IndicateurService::class); $helper = new IndicateurViewHelper(); $helper->setIndicateurService($indicateurService); return $helper; } } No newline at end of file src/UnicaenIndicateur/View/Helper/ItemViewHelperInterface.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; interface ItemViewHelperInterface { /** Retourne le header du tableau */ public function getHeader(array $data) : string ; /** Retourne la line du tableau associée avec l'item à la position $position */ public function getItem(array $data, int $position) : string ; } No newline at end of file Loading
config/merged/indicateur.config.php +11 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ use UnicaenIndicateur\Form\Indicateur\IndicateurHydratorFactory; use UnicaenIndicateur\Provider\Privilege\IndicateurPrivileges; use UnicaenIndicateur\Service\Indicateur\IndicateurService; use UnicaenIndicateur\Service\Indicateur\IndicateurServiceFactory; use UnicaenIndicateur\View\Helper\DefaultItemViewHelper; use UnicaenIndicateur\View\Helper\IndicateurViewHelperFactory; use UnicaenPrivilege\Guard\PrivilegeController; use Laminas\Mvc\Console\Router\Simple; use Laminas\Router\Http\Literal; Loading Loading @@ -200,6 +202,13 @@ return [ 'factories' => [ IndicateurHydrator::class => IndicateurHydratorFactory::class, ], ] ], 'view_helpers' => [ 'invokables' => [ 'defaultItem' => DefaultItemViewHelper::class, ], 'factories' => [ 'indicateur' => IndicateurViewHelperFactory::class, ], ], ]; No newline at end of file
src/UnicaenIndicateur/View/Helper/DefaultItemViewHelper.php 0 → 100644 +36 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; use Laminas\View\Helper\AbstractHelper; class DefaultItemViewHelper extends AbstractHelper implements ItemViewHelperInterface { public function getHeader(array $data) : string { $headers = $data[0]; $texte = "<thead>"; $texte .= "<tr>"; foreach ($headers as $header) { $texte .= "<th>"; $texte .= $header; $texte .= "</th>"; } $texte .= "</tr>"; $texte .= "</thead>"; return $texte; } public function getItem(array $data, int $position) : string { $values = $data[1][$position]; $texte = "<tr>"; foreach ($values as $value) { $texte .= "<td>"; $texte .= $value; $texte .= "</td>"; } $texte .= "</tr>"; return $texte; } } No newline at end of file
src/UnicaenIndicateur/View/Helper/IndicateurViewHelper.php 0 → 100644 +31 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; use Laminas\View\Helper\AbstractHelper; use Laminas\View\Renderer\PhpRenderer; use Laminas\View\Resolver\TemplatePathStack; use UnicaenIndicateur\Entity\Db\Indicateur; use UnicaenIndicateur\Service\Indicateur\IndicateurServiceAwareTrait; class IndicateurViewHelper extends AbstractHelper { use IndicateurServiceAwareTrait; /** * @param Indicateur $indicateur * @param array $options * @return \Laminas\View\Helper\Partial|string * * La clef $options['ViewHelper'] permet d'indiquer le ViewHelperpour réaliser l'affichage * attention celui-ci doit implementer l'interface ItemViewHelperInterface */ public function __invoke(Indicateur $indicateur, array $options = []) { /** @var PhpRenderer $view */ $view = $this->getView(); $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]])); $data = $this->getIndicateurService()->getIndicateurData($indicateur); return $view->partial('indicateur', ['indicateur' => $indicateur, 'data' => $data, 'options' => $options]); } } No newline at end of file
src/UnicaenIndicateur/View/Helper/IndicateurViewHelperFactory.php 0 → 100644 +29 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; use UnicaenIndicateur\Service\Indicateur\IndicateurService; class IndicateurViewHelperFactory { /** * @param ContainerInterface $container * @return IndicateurViewHelper * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container) : IndicateurViewHelper { /** * @var IndicateurService $indicateurService */ $indicateurService = $container->get(IndicateurService::class); $helper = new IndicateurViewHelper(); $helper->setIndicateurService($indicateurService); return $helper; } } No newline at end of file
src/UnicaenIndicateur/View/Helper/ItemViewHelperInterface.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?php namespace UnicaenIndicateur\View\Helper; interface ItemViewHelperInterface { /** Retourne le header du tableau */ public function getHeader(array $data) : string ; /** Retourne la line du tableau associée avec l'item à la position $position */ public function getItem(array $data, int $position) : string ; } No newline at end of file