GraphAware\Neo4j\OGM\Tests\Integration\Model\Person::addRole PHP Method

addRole() public method

public addRole ( Movie $movie, $roles = null )
$movie Movie
    public function addRole(Movie $movie, $roles = null)
    {
        $roles = is_array($roles) ? $roles : [];
        $this->roles->add(new Role($this, $movie, $roles));
    }

Usage Example

コード例 #1
0
 /**
  * @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"})');
 }