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

Ajout du view helpers des formations gourpes et optionify

parent e2a79b57
Loading
Loading
Loading
Loading
+8 −2
Changes for module/Application/config/merged/formation.config.php: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ use Application\Service\Formation\FormationThemeService;
use Application\Service\Formation\FormationThemeServiceFactory;
use Application\Service\ParcoursDeFormation\ParcoursDeFormationService;
use Application\Service\ParcoursDeFormation\ParcoursDeFormationServiceFactory;
use Application\View\Helper\FormationGroupeViewHelper;
use Application\View\Helper\SpecificitePosteViewHelper;
use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal;
use Zend\Router\Http\Segment;
@@ -374,6 +376,10 @@ return [
            FormationHydrator::class => FormationHydratorFactory::class,
            FormationGroupeHydrator::class => FormationGroupeHydratorFactory::class,
        ],
    ]

    ],
    'view_helpers' => [
        'invokables' => [
            'formationGroupe' => FormationGroupeViewHelper::class,
        ],
    ],
];
 No newline at end of file
+21 −1
Changes for module/Application/src/Application/Service/Formation/FormationGroupeService.php: 21 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Service\Formation;

use Application\Entity\Db\FormationGroupe;
use Application\Service\GestionEntiteHistorisationTrait;
use Application\Service\RendererAwareTrait;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\QueryBuilder;
use UnicaenApp\Exception\RuntimeException;
@@ -14,6 +15,7 @@ class FormationGroupeService {
//    use UserServiceAwareTrait;
//    use DateTimeAwareTrait;
    use GestionEntiteHistorisationTrait;
    use RendererAwareTrait;

    /** GESTION DES ENTITES *******************************************************************************************/

@@ -94,6 +96,23 @@ class FormationGroupeService {
        return $result;
    }

    /**
     * @param FormationGroupe $groupe
     * @return array
     */
    public function optionify(FormationGroupe $groupe) {
        $res = $this->renderer->formationGroupe($groupe);

        $this_option = [
            'value' =>  $groupe->getId(),
            'attributes' => [
                'data-content' => $res . "    ".$groupe->getLibelle(),
            ],
            'label' => $groupe->getLibelle(),
        ];
        return $this_option;
    }

    /**
     * @return array
     */
@@ -102,7 +121,8 @@ class FormationGroupeService {
        $groupes = $this->getFormationsGroupes();
        $array = [];
        foreach ($groupes as $groupe) {
            $array[$groupe->getId()] = $groupe->getLibelle();
            $option = $this->optionify($groupe);
            $array[$groupe->getId()] = $option;
        }
        return $array;
    }
+5
Changes for module/Application/src/Application/Service/Formation/FormationGroupeServiceFactory.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Application\Service\Formation;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use UnicaenUtilisateur\Service\User\UserService;
use Zend\View\Renderer\PhpRenderer;

class FormationGroupeServiceFactory {

@@ -17,10 +18,14 @@ class FormationGroupeServiceFactory {
        $entityManager = $container->get('doctrine.entitymanager.orm_default');
        $userService = $container->get(UserService::class);

        /* @var PhpRenderer $renderer  */
        $renderer = $container->get('ViewRenderer');

        /** @var FormationGroupeService $service */
        $service = new FormationGroupeService();
        $service->setEntityManager($entityManager);
        $service->setUserService($userService);
        $service->setRenderer($renderer);
        return $service;
    }
}
+29
Changes for module/Application/src/Application/View/Helper/FormationGroupeViewHelper.php: 29 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;

use Application\Entity\Db\FormationGroupe;
use Application\Service\FicheMetierEtat\FicheMetierEtatServiceAwareTrait;
use Application\View\Renderer\PhpRenderer;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Helper\Partial;
use Zend\View\Resolver\TemplatePathStack;

class FormationGroupeViewHelper extends AbstractHelper
{
    use FicheMetierEtatServiceAwareTrait;

    /**
     * @param FormationGroupe $groupe
     * @param array $options
     * @return string|Partial
     */
    public function __invoke($groupe, $options = ['mode' => 'affichage'])
    {
        /** @var PhpRenderer $view */
        $view = $this->getView();
        $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]]));

        return $view->partial('formation-groupe', ['groupe' => $groupe, 'options' => $options]);
    }
}
 No newline at end of file
+1 −2
Changes for module/Application/src/Application/View/Helper/partial/fiche-metier.phtml: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ if (isset($options['sans-titre'])) $sansTitre = ($options['sans-titre'] === true
            <?php endif; ?>
        </div>
    </div>
<?php endif; ?>

    <div class="row">
    <div class="col-md-8">
@@ -101,7 +100,7 @@ if (isset($options['sans-titre'])) $sansTitre = ($options['sans-titre'] === true
        </div>
    </div>
</div>

<?php endif; ?>
<br/>

<div class="main">
Loading