public function addRole(Movie $movie, $roles = null) { $roles = is_array($roles) ? $roles : []; $this->roles->add(new Role($this, $movie, $roles)); }
/** * @group re-cascade-persist */ public function testRelationshipEntityCanBeAdded() { $this->clearDb(); $person = new Person('ikwattro'); $movie = new Movie('Neo4j on the rocks'); $person->addRole($movie, ['Super Actor']); $this->em->persist($person); $this->em->flush(); $this->assertGraphExist('(p:Person {name:"ikwattro"})-[r:ACTED_IN {roles: ["Super Actor"]}]->(m:Movie {title:"Neo4j on the rocks"})'); }