-
-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Milestone
Description
I want to use this library without laminas forms. When I try to extract an entity with a many-to-many relationship, I receive the PersistentCollection in the result array. Association extraction is not covered in the documentation. Could you please help me?
Here is my example entities:
#[ORM\Entity]
class Order extends IdEntity
{
#[ORM\Id]
#[ORM\Column(type: 'string')]
protected string $id;
#[ORM\ManyToMany(targetEntity: Tag::class)]
public Collection $tags;
public function __construct()
{
$this->id = uniqid('order');
$this->tags = new ArrayCollection();
}
public function getId():string
{
return $this->id;
}
public function getTags():Collection
{
return $this->tags;
}
}
#[ORM\Entity]
final class Tag extends IdEntity
{
#[ORM\Id]
#[ORM\Column(type: 'string')]
public string $id;
#[ORM\Column(type: 'string')]
public string $name;
public function __construct()
{
$this->id = uniqid('tag');
}
public function getId():string
{
return $this->id;
}
public function getName():string
{
return $this->name;
}
}Here is my code where i'm trying to extract data:
$order = $entityManager->find(Order::class,'order641c4493aa1ad');
$doctrineHydrator = new \Doctrine\Laminas\Hydrator\DoctrineObject($entityManager);
$data = $doctrineHydrator->extract($order);
print_r(get_debug_type($data['tags']));Here is output:
Doctrine\ORM\PersistentCollection
I'm expecting array with tags there.