protected function cleanup($entityName, array $collection, array $conditions)
    {
        if (!$existing = $this->isCleanupNecessary($entityName, $conditions)) {
            return;
        }

        $identifiers = [];
        foreach ($collection as $instance) {
            $identifiers[] = $this->identifyEntity($instance, $entityName);
        }

        foreach ($existing as $instance) {
            if (in_array($this->identifyEntity($instance, $entityName), $identifiers)) {
                continue;
            }

            $this->storage->delete($instance, $entityName)->execute();
        }

        return;
    }
protected function cleanup($entityName, array $collection, array $conditions)
    {
        if (!$existing = $this->isCleanupNecessary($entityName, $conditions)) {
            return;
        }

        $identifiers = [];
        foreach ($collection as $instance) {
            $identifiers[] = $this->identifyEntity($instance, $entityName);
        }

        foreach ($existing as $instance) {
            if (in_array($this->identifyEntity($instance, $entityName), $identifiers)) {
                continue;
            }

            $this->storage->delete($instance, $entityName)->execute();
        }

        return;
    }
protected function cleanup ( $ entityName , array $ collection , array $ conditions ) { if ( ! $ existing = $ this -> isCleanupNecessary ( $ entityName , $ conditions ) ) { return ; } $ identifiers = [ ] ; foreach ( $ collection as $ instance ) { $ identifiers [ ] = $ this -> identifyEntity ( $ instance , $ entityName ) ; } foreach ( $ existing as $ instance ) { if ( in_array ( $ this -> identifyEntity ( $ instance , $ entityName ) , $ identifiers ) ) { continue ; } $ this -> storage -> delete ( $ instance , $ entityName ) -> execute ( ) ; } return ; }
Removes obsolete entities that match conditions but don't exist in collection

@param string $entityName
@param array  $collection
@param array  $conditions
Removes obsolete entities that match conditions but don t exist in collection