public function _cleanup(&$collection)
    {
        $name = $this->name();

        if ($this->isMany()) {
            foreach ($collection as $index => $entity) {
                if (is_object($entity)) {
                    $entity->{$name} = [];
                } else {
                    $collection[$index][$name] = [];
                }
            }
            return;
        }

        foreach ($collection as $index => $entity) {
            if (is_object($entity)) {
                unset($entity->{$name});
            } else {
                unset($entity[$name]);
            }
        }
    }
public function _cleanup(&$collection)
    {
        $name = $this->name();

        if ($this->isMany()) {
            foreach ($collection as $index => $entity) {
                if (is_object($entity)) {
                    $entity->{$name} = [];
                } else {
                    $collection[$index][$name] = [];
                }
            }
            return;
        }

        foreach ($collection as $index => $entity) {
            if (is_object($entity)) {
                unset($entity->{$name});
            } else {
                unset($entity[$name]);
            }
        }
    }
public function _cleanup ( & $ collection ) { $ name = $ this -> name ( ) ; if ( $ this -> isMany ( ) ) { foreach ( $ collection as $ index => $ entity ) { if ( is_object ( $ entity ) ) { $ entity -> { $ name } = [ ] ; } else { $ collection [ $ index ] [ $ name ] = [ ] ; } } return ; } foreach ( $ collection as $ index => $ entity ) { if ( is_object ( $ entity ) ) { unset ( $ entity -> { $ name } ) ; } else { unset ( $ entity [ $ name ] ) ; } } }
Unsets the relationship attached to a collection en entities.

@param  mixed  $collection An collection to "clean up".
Unsets the relationship attached to a collection en entities .