GraphAware\Neo4j\OGM\Tests\Integration\Model\Team::addMembership PHP Метод

addMembership() публичный Метод

public addMembership ( PlaysInTeam $playsInTeam )
$playsInTeam PlaysInTeam
    public function addMembership(PlaysInTeam $playsInTeam)
    {
        if (!$this->memberships->contains($playsInTeam)) {
            $this->memberships->add($playsInTeam);
        }
    }

Usage Example

Пример #1
0
 public function addToTeam(Team $team, $timestamp = null)
 {
     if (null !== $this->playsIn) {
         throw new \InvalidArgumentException('You must remove the current membership before adding a new one');
     }
     $dt = new \DateTime('NOW', new \DateTimeZone('UTC'));
     $time = null !== $timestamp ? $timestamp : $dt->getTimestamp();
     $membership = new PlaysInTeam($this, $team, $time);
     $this->playsIn = $membership;
     $team->addMembership($membership);
 }