Reputation: 35
This is my omg class :
/**
* @OGM\Node(label="Personne")
*/
class Personne
{
/**
* @OGM\GraphId()
*/
protected $id;
/**
* @OGM\Property(type="string")
*/
protected $nom;
/**
* @OGM\Relationship(targetEntity="Personne", type="SUIT", direction="OUTGOING")
*/
protected $amis;
And I use this code :
$marc = $this->em->getRepository(Personne::class)->findOneBy('nom', 'marc');
print_r($marc->getAmis());
But it returns only 1 relationship, not all, what is wrong ?
Upvotes: 1
Views: 107
Reputation: 20185
It is returning only one related "Personne" because you didn't defined the amis
properties as a collection in the mapping :
Add collection=true
in the @OGM\Relationship
annotation.
NB: In PHP 7.1, typed properties can make it in, a future version of the OGM might take advantage of it (meaning then that this version would be 7.1+ only)
Actually I think the OGM should throw an exception in case there is more than one relationship found.
Upvotes: 1