src/acdhOeaw/schema/SchemaObject.php
protected function findResource(bool $create = true,
                                    bool $uploadBinary = true, string $path = ''): bool {
        $ids    = $this->getIds();
        echo self::$debug ? "searching for " . implode(', ', $ids) . "\n" : "";
        $result = '';

        try {
            $this->res = $this->fedora->getResourceByIds($ids);
            $result    = 'found in cache';
        } catch (NotFound $e) {
            if (!$create) {
                throw $e;
            }

            $meta      = $this->getMetadata();
            $this->fedora->fixMetadataReferences($meta);
            $binary    = $uploadBinary ? $this->getBinaryData() : '';
            $method    = substr($path, -1) == '/' || $path === '' ? 'POST' : 'PUT';
            $this->res = $this->fedora->createResource($meta, $binary, $path, $method);
            $result    = 'not found - created';
        }

        echo self::$debug ? "\t" . $result . " - " . $this->res->getUri(true) . "\n" : "";
        return $result == 'not found - created';
    }
protected function findResource(bool $create = true,
                                    bool $uploadBinary = true, string $path = ''): bool {
        $ids    = $this->getIds();
        echo self::$debug ? "searching for " . implode(', ', $ids) . "\n" : "";
        $result = '';

        try {
            $this->res = $this->fedora->getResourceByIds($ids);
            $result    = 'found in cache';
        } catch (NotFound $e) {
            if (!$create) {
                throw $e;
            }

            $meta      = $this->getMetadata();
            $this->fedora->fixMetadataReferences($meta);
            $binary    = $uploadBinary ? $this->getBinaryData() : '';
            $method    = substr($path, -1) == '/' || $path === '' ? 'POST' : 'PUT';
            $this->res = $this->fedora->createResource($meta, $binary, $path, $method);
            $result    = 'not found - created';
        }

        echo self::$debug ? "\t" . $result . " - " . $this->res->getUri(true) . "\n" : "";
        return $result == 'not found - created';
    }
protected function findResource ( bool $ create = true , bool $ uploadBinary = true , string $ path = '' ) : bool { $ ids = $ this -> getIds ( ) ; echo self :: $ debug ? "searching for " . implode ( ', ' , $ ids ) . "\n" : "" ; $ result = '' ; try { $ this -> res = $ this -> fedora -> getResourceByIds ( $ ids ) ; $ result = 'found in cache' ; } catch ( NotFound $ e ) { if ( ! $ create ) { throw $ e ; } $ meta = $ this -> getMetadata ( ) ; $ this -> fedora -> fixMetadataReferences ( $ meta ) ; $ binary = $ uploadBinary ? $ this -> getBinaryData ( ) : '' ; $ method = substr ( $ path , - 1 ) == '/' || $ path === '' ? 'POST' : 'PUT' ; $ this -> res = $ this -> fedora -> createResource ( $ meta , $ binary , $ path , $ method ) ; $ result = 'not found - created' ; } echo self :: $ debug ? "\t" . $ result . " - " . $ this -> res -> getUri ( true ) . "\n" : "" ; return $ result == 'not found - created' ; }
Tries to find a repository resource representing a given object.

@param bool $create should repository resource be created if it was not
found?
@param bool $uploadBinary should binary data of the real-world entity
be uploaded uppon repository resource creation?
@param string $path where to create a resource (if it does not exist).
If it it ends with a "/", the resource will be created as a child of
a given collection). All the parents in the Fedora resource tree have
to exist (you can not create "/foo/bar" if "/foo" does not exist already).
@return boolean if a repository resource was found
Tries to find a repository resource representing a given object .