In a `Network` class I have the following property
/**
* @var Collection<Person>
*/
#[ORM\OneToMany]
#[ORM\JoinTable(name: 'networks_people')]
public $people;
The `Person` model looking like this
class Person
{
#[ORM\ManyToOne]
public ?Identity $identity = null;
#[ORM\Column]
public string $name;
}
The collection gives me a method to “match” on items in the collection via the `matching` method and `Criteria` object
So I use that in this domain method
public function enroll(Identity $identity, Role $role = Role::Member)
{
if (
$this->people->matching(
Criteria::create()->andWhere(
Criteria::expr()->eq('identity', $identity)
)
)->isEmpty()
) {
$person = Person::fromIdentity($identity);
$this->people->add($person);
}
}
But then the doctrine metadata doesn’t seem to know about the `identity` property of the `Person` model. A error returned looks like this
Warning: Undefined array key "identity" in /var/www/html/Packages/Libraries/doctrine/orm/src/Mapping/DefaultQuoteStrategy.php line 30
Because the “identity” is not added as a “column” because it’s a “collection”.
Strange thing is, I originally had the same functionality, but in the “Identity” model
public function join(Network $network): self
{
if (
$network->people->matching(
new Criteria(Criteria::expr()->eq('identity', $this))
)->isEmpty()
) {
$person = Person::fromIdentity($this);
$network->people->add($person);
}
return $this;
}
Where it was perfect fine and the matching was returning a bool.
Anyone knows if this is a FlowAnnotationDriver missing feature or a Doctrine ORM 2.20 limitation?