public function insert($target, $config = array())
    {
        if (AnHelperArray::isIterable($target)) {
            $targets = AnHelperArray::unique($target);
            $relations = new AnObjectSet();
            foreach ($target as $target) {
                $relations->insert($this->insert($target, $config));
            }

            return $relations;
        }

        $data = array(
                $this->_property => $this->_root,
                $this->_target_property => $target,
            );

        //shouldn't be able to add the same entity into  the same collection		
        $relation = $this->_child->findOrAddNew($data, $config);

        return $relation;
    }
public function insert($target, $config = array())
    {
        if (AnHelperArray::isIterable($target)) {
            $targets = AnHelperArray::unique($target);
            $relations = new AnObjectSet();
            foreach ($target as $target) {
                $relations->insert($this->insert($target, $config));
            }

            return $relations;
        }

        $data = array(
                $this->_property => $this->_root,
                $this->_target_property => $target,
            );

        //shouldn't be able to add the same entity into  the same collection		
        $relation = $this->_child->findOrAddNew($data, $config);

        return $relation;
    }
public function insert ( $ target , $ config = array ( ) ) { if ( AnHelperArray :: isIterable ( $ target ) ) { $ targets = AnHelperArray :: unique ( $ target ) ; $ relations = new AnObjectSet ( ) ; foreach ( $ target as $ target ) { $ relations -> insert ( $ this -> insert ( $ target , $ config ) ) ; } return $ relations ; } $ data = array ( $ this -> _property => $ this -> _root , $ this -> _target_property => $ target , ) ; //shouldn't be able to add the same entity into  the same collection		 $ relation = $ this -> _child -> findOrAddNew ( $ data , $ config ) ; return $ relation ; }
Insert an entity to the aggregation. If multiple target is passed then
add the all of them to the collection. It prevents adding the same
entity into the its existing collection.

@param AnDomainEntityAbstract|array $target
@param array                        $config

@return AnDomainEntityAbstract
Insert an entity to the aggregation . If multiple target is passed then add the all of them to the collection . It prevents adding the same entity into the its existing collection .