public function associate($type, array $items = null)
    {
        if ($this->getOwner() === null) {
            throw new DomainException('Unable to associate relations to a collection that does not have an owning entity!');
        }
        if ($type instanceof Entity\Content) {
            $this->addEntity((string) $type->getContenttype(), $type->getId(), $this->getOwner());

            return;
        }

        if (is_iterable($type)) {
            foreach ($type as $entity) {
                if ($entity instanceof Entity\Content) {
                    $this->associate($entity);
                }
            }

            return;
        }

        foreach ($items as $item) {
            $this->addEntity($type, $item, $this->getOwner());
        }
    }
public function associate($type, array $items = null)
    {
        if ($this->getOwner() === null) {
            throw new DomainException('Unable to associate relations to a collection that does not have an owning entity!');
        }
        if ($type instanceof Entity\Content) {
            $this->addEntity((string) $type->getContenttype(), $type->getId(), $this->getOwner());

            return;
        }

        if (is_iterable($type)) {
            foreach ($type as $entity) {
                if ($entity instanceof Entity\Content) {
                    $this->associate($entity);
                }
            }

            return;
        }

        foreach ($items as $item) {
            $this->addEntity($type, $item, $this->getOwner());
        }
    }
public function associate ( $ type , array $ items = null ) { if ( $ this -> getOwner ( ) === null ) { throw new DomainException ( 'Unable to associate relations to a collection that does not have an owning entity!' ) ; } if ( $ type instanceof Entity \ Content ) { $ this -> addEntity ( ( string ) $ type -> getContenttype ( ) , $ type -> getId ( ) , $ this -> getOwner ( ) ) ; return ; } if ( is_iterable ( $ type ) ) { foreach ( $ type as $ entity ) { if ( $ entity instanceof Entity \ Content ) { $ this -> associate ( $ entity ) ; } } return ; } foreach ( $ items as $ item ) { $ this -> addEntity ( $ type , $ item , $ this -> getOwner ( ) ) ; } }
Associate related items by type and identifiers

@param string|Entity\Content $type
@param array|null            $items
Associate related items by type and identifiers