symfonyjmsjmsserializerbundlejms-serializer

JMSSerializer hasData deprecated


I have an entity with relatives paths. If those links are serialized, I want to change them to an absolute path.

class EntityA
{
    /**
     * @var string
     *
     * @Serializer\Expose
     * @Serializer\Groups({"A"})
     */
    private $pathA;
}

I add an event subscribe on post_serialize. I can change the value of the field with

    $visitor->visitProperty(new StaticPropertyMetadata('', 'path_a', $absolutePath), $absolutePath);

BUT I don't that field if absolutePath wasn't in the groups A.

Before, I used $visitor->hasData('path_a') but it's now deprecated.

What's the new way to change path_a ONLY if it exists in the visitor:$data and don't break my serializer groups?


Solution

  • After 3.9.0 version method hasData is not deprecated.

    CHANGELOG