Nextras\Orm\Relationships\HasMany::add PHP Метод

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

public add ( $entity )
    public function add($entity)
    {
        if ($this->updatingReverseRelationship) {
            return null;
        }
        $entity = $this->createEntity($entity);
        $entityHash = spl_object_hash($entity);
        if (isset($this->toRemove[$entityHash])) {
            unset($this->toRemove[$entityHash]);
        } else {
            $this->toAdd[$entityHash] = $entity;
        }
        $this->updateRelationshipAdd($entity);
        $this->modify();
        $this->wasLoaded = $this->wasLoaded || $this->collection !== null;
        $this->collection = null;
        return $entity;
    }