How to generate relationship without ArrayCollection type (with Doctrine)

208 Views Asked by At

I want generate my entities without the dependency Doctrine\Orm\PersistentCollection.

All fields of my entity are mapped in Entity.orm.xml

I would like change the type of the return relationship (ArrayCollection to simple array)

Team.orm.xml :

<doctrine-mapping>
    <entity  name="App\Entity\Team" table="team" repository-class="App\Repository\TeamRepository">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO"/>
        </id>
        <field name="name" type="string"/>
        <many-to-many field="users" target-entity="User"/>
    </entity>
</doctrine-mapping>

My property users (isn't in __construct function):

/** @var array<int, User[]> $users */
private array $users;

I would be happy to receive any ideas or propositions in order to develop our reflections on this issue. Thanks !

0

There are 0 best solutions below