We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to use an handler only for deserialization. Upon serialization, the default handler should be used.
If I try to define a custom handler, registering it like this way:
app.serializer.relation_deserialization_handler: class: App\Serializer\RelationsHandler arguments: ['@doctrine.orm.entity_manager'] tags: - { name: jms_serializer.handler, type: Relation, direction: deserialization, format: json, method: deserialize }
<?php declare(strict_types=1); namespace App\Serializer; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use JMS\Serializer\Context; use JMS\Serializer\Visitor\DeserializationVisitorInterface; class RelationsHandler { private $manager; public function __construct(EntityManagerInterface $manager) { $this->manager = $manager; } public function deserialize( DeserializationVisitorInterface $visitor, $relation, array $type, Context $context ) { $className = isset($type['params'][0]['name']) ? $type['params'][0]['name'] : null; } }
Class Relation does not exist in jms\metadata\src\MetadataFactory.php line 175.
I'm using it on a regular PHP property:
<?php declare(strict_types=1); namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; /** * @ORM\Entity() * @ORM\Table("customer") */ class Customer { /** * @ORM\ManyToOne(targetEntity="Agent") * @ORM\JoinColumn() * * @Serializer\Type("Relation<App\Entity\Agent>") * @Serializer\Groups({"customers:get_all", "customers:get_one", "customers:create"}) */ public ?Agent $agent = null; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I want to use an handler only for deserialization. Upon serialization, the default handler should be used.
If I try to define a custom handler, registering it like this way:
I'm using it on a regular PHP property:
The text was updated successfully, but these errors were encountered: