Commit 73b34db5 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Possibilité de ne pas hydrater cetaines propriétés de manière générique pour...

Possibilité de ne pas hydrater cetaines propriétés de manière générique pour le faire dans une classe descendante
parent a50fe95a
Loading
Loading
Loading
Loading
+6 −0
Changes for module/Application/src/Application/Hydrator/GenericHydrator.php: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ class GenericHydrator implements HydratorInterface

    protected $elements       = [];

    protected $noGenericParse = [];



    public function __construct(EntityManager $entityManager, array $elements = [])
@@ -27,6 +29,7 @@ class GenericHydrator implements HydratorInterface
    {
        $data = [];
        foreach ($this->elements as $name => $params) {
            if (!in_array($name, $this->noGenericParse)) {
                $type   = isset($params['type']) ? $params['type'] : null;
                $getter = isset($params['getter']) ? $params['getter'] : null;

@@ -61,6 +64,7 @@ class GenericHydrator implements HydratorInterface

                $data[$name] = $value;
            }
        }

        return $data;
    }
@@ -70,6 +74,7 @@ class GenericHydrator implements HydratorInterface
    public function hydrate(array $data, $object)
    {
        foreach ($this->elements as $name => $params) {
            if (!in_array($name, $this->noGenericParse)) {
                $type     = isset($params['type']) ? $params['type'] : null;
                $setter   = isset($params['setter']) ? $params['setter'] : 'set' . ucfirst($name);
                $readOnly = isset($params['readonly']) ? (bool)$params['readonly'] : false;
@@ -106,6 +111,7 @@ class GenericHydrator implements HydratorInterface
                }
            }
        }
    }