src/acdhOeaw/fedora/FedoraResource.php
public function delete(bool $deep = false, bool $children = false,
                           bool $references = false) {
        $this->uri      = $this->fedora->sanitizeUri($this->getUri());
        $fedoraChildren = $this->getMetadata()->allResources(self::CONTAINS_PROP);
        if (count($fedoraChildren) > 0) {
            throw new RuntimeException("A resource has Fedora children");
        }
        $request = new Request('DELETE', $this->uri);
        $this->fedora->sendRequest($request);
        $this->fedora->getCache()->delete($this);
        if ($deep) {
            $request = new Request('DELETE', $this->uri . '/fcr:tombstone');
            $this->fedora->sendRequest($request);
        }

        try {
            $this->getAcl()->deleteAcl();
        } catch (NotFound $e) {
            
        } catch (Deleted $e) {
            
        }

        if ($children) {
            foreach ($this->getChildren() as $i) {
                $i->delete($deep, $children, $references);
            }
        }

        if ($references) {
            $id      = $this->getId();
            $query   = new SimpleQuery('SELECT * WHERE {?res ?prop ?@}');
            $query->setValues(array($id));
            $results = $this->fedora->runQuery($query);
            foreach ($results as $i) {
                try {
                    $res  = $this->fedora->getResourceByUri($i->res);
                    $meta = $res->getMetadata();
                    foreach ($meta->propertyUris() as $prop) {
                        $meta->deleteResource($prop, $id);
                    }
                    $res->setMetadata($meta);
                    $res->updateMetadata(self::OVERWRITE);
                } catch (Deleted $e) {
                    
                } catch (NotFound $e) {
                    
                }
            }
        }
    }
public function delete(bool $deep = false, bool $children = false,
                           bool $references = false) {
        $this->uri      = $this->fedora->sanitizeUri($this->getUri());
        $fedoraChildren = $this->getMetadata()->allResources(self::CONTAINS_PROP);
        if (count($fedoraChildren) > 0) {
            throw new RuntimeException("A resource has Fedora children");
        }
        $request = new Request('DELETE', $this->uri);
        $this->fedora->sendRequest($request);
        $this->fedora->getCache()->delete($this);
        if ($deep) {
            $request = new Request('DELETE', $this->uri . '/fcr:tombstone');
            $this->fedora->sendRequest($request);
        }

        try {
            $this->getAcl()->deleteAcl();
        } catch (NotFound $e) {
            
        } catch (Deleted $e) {
            
        }

        if ($children) {
            foreach ($this->getChildren() as $i) {
                $i->delete($deep, $children, $references);
            }
        }

        if ($references) {
            $id      = $this->getId();
            $query   = new SimpleQuery('SELECT * WHERE {?res ?prop ?@}');
            $query->setValues(array($id));
            $results = $this->fedora->runQuery($query);
            foreach ($results as $i) {
                try {
                    $res  = $this->fedora->getResourceByUri($i->res);
                    $meta = $res->getMetadata();
                    foreach ($meta->propertyUris() as $prop) {
                        $meta->deleteResource($prop, $id);
                    }
                    $res->setMetadata($meta);
                    $res->updateMetadata(self::OVERWRITE);
                } catch (Deleted $e) {
                    
                } catch (NotFound $e) {
                    
                }
            }
        }
    }
public function delete ( bool $ deep = false , bool $ children = false , bool $ references = false ) { $ this -> uri = $ this -> fedora -> sanitizeUri ( $ this -> getUri ( ) ) ; $ fedoraChildren = $ this -> getMetadata ( ) -> allResources ( self :: CONTAINS_PROP ) ; if ( count ( $ fedoraChildren ) > 0 ) { throw new RuntimeException ( "A resource has Fedora children" ) ; } $ request = new Request ( 'DELETE' , $ this -> uri ) ; $ this -> fedora -> sendRequest ( $ request ) ; $ this -> fedora -> getCache ( ) -> delete ( $ this ) ; if ( $ deep ) { $ request = new Request ( 'DELETE' , $ this -> uri . '/fcr:tombstone' ) ; $ this -> fedora -> sendRequest ( $ request ) ; } try { $ this -> getAcl ( ) -> deleteAcl ( ) ; } catch ( NotFound $ e ) { } catch ( Deleted $ e ) { } if ( $ children ) { foreach ( $ this -> getChildren ( ) as $ i ) { $ i -> delete ( $ deep , $ children , $ references ) ; } } if ( $ references ) { $ id = $ this -> getId ( ) ; $ query = new SimpleQuery ( 'SELECT * WHERE {?res ?prop ?@}' ) ; $ query -> setValues ( array ( $ id ) ) ; $ results = $ this -> fedora -> runQuery ( $ query ) ; foreach ( $ results as $ i ) { try { $ res = $ this -> fedora -> getResourceByUri ( $ i -> res ) ; $ meta = $ res -> getMetadata ( ) ; foreach ( $ meta -> propertyUris ( ) as $ prop ) { $ meta -> deleteResource ( $ prop , $ id ) ; } $ res -> setMetadata ( $ meta ) ; $ res -> updateMetadata ( self :: OVERWRITE ) ; } catch ( Deleted $ e ) { } catch ( NotFound $ e ) { } } } }
Removes the resource from the Fedora.

Please remember searching for children and references is done using
a SPARQL query so any changes made since the beginning of the transaction
won't be taken into account.
@param bool $deep should tombstone resource will be deleted?
@param bool $children should children be removed?
@param bool $references should references to the resource be removed?
(applies also for children when `$children == true`)
Removes the resource from the Fedora .