Commit b03e3797 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Factory-sation du FormControlGroup

Mise en place d'un tableau pour lister les exception d'usage de vues
parent 49d87ce3
Loading
Loading
Loading
Loading
+12 −8
Changes for src/UnicaenApp/Form/View/Helper/FormControlGroup.php: 12 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -50,6 +50,14 @@ class FormControlGroup extends AbstractHelper
     */
    protected $helpContent = ['before' => '', 'after' => ''];

    /**
     * @var string[]
     */
    protected $helpers = [
        Date::class           => 'formDate',
        DateInfSup::class     => 'formDateInfSup',
    ];



    /**
@@ -84,14 +92,10 @@ class FormControlGroup extends AbstractHelper
        $this->normalizeElement($element);
        $this->customFromOptions($element);

        /* Bypass pour des éléments spécofiques */
        if ($element instanceof Date) {
            $helper = $this->getView()->plugin('formDate');

            return $helper($element);
        }
        if ($element instanceof DateInfSup) {
            $helper = $this->getView()->plugin('formDateInfSup');
        /* Bypass pour des éléments spécifiques */
        $class = get_class($element);
        if (array_key_exists($class, $this->helpers)) {
            $helper = $this->getView()->plugin($this->helpers[$class]);

            return $helper($element);
        }
+28
Changes for src/UnicaenApp/Form/View/Helper/FormControlGroupFactory.php: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenApp\Form\View\Helper;

use Zend\ServiceManager\ServiceLocatorInterface as ContainerInterface;

/**
 * Description of FormControlGroupFactory
 *
 * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr>
 */
class FormControlGroupFactory
{

    /**
     * @param ContainerInterface $container
     * @param string             $requestedName
     * @param array|null         $options
     *
     * @return FormControlGroup
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null)
    {
        $vh = new FormControlGroup();

        return $vh;
    }
}
 No newline at end of file