diff --git a/src/acdhOeaw/arche/lib/ingest/Indexer.php b/src/acdhOeaw/arche/lib/ingest/Indexer.php index 47df8e1..6fc5c5e 100644 --- a/src/acdhOeaw/arche/lib/ingest/Indexer.php +++ b/src/acdhOeaw/arche/lib/ingest/Indexer.php @@ -599,7 +599,7 @@ private function indexEntry(DirectoryIterator $i) { $location = self::getRelPath(self::sanitizePath($i->getPathname()), $this->containerDir); $id = $this->containerToUriPrefix . str_replace('%2F', '/', rawurlencode($location)); $class = $i->isDir() ? $this->collectionClass : $this->binaryClass; - $parent = $this->parent === null ? null : $this->parent->getUri(); + $parent = isset($this->parent) ? $this->parent->getUri() : null; $file = new File($this->repo, $id, $i->getPathname(), $location, $class, $parent); if ($this->metaLookup !== null) { $file->setMetaLookup($this->metaLookup, $this->metaLookupRequire); diff --git a/src/acdhOeaw/arche/lib/ingest/schema/File.php b/src/acdhOeaw/arche/lib/ingest/schema/File.php index 2484777..b188484 100644 --- a/src/acdhOeaw/arche/lib/ingest/schema/File.php +++ b/src/acdhOeaw/arche/lib/ingest/schema/File.php @@ -42,6 +42,9 @@ */ class File extends SchemaObject { + const GUZZLE_PSR7_V1_MIME_FUNC = '\GuzzleHttp\Psr7\mimetype_from_filename'; + const GUZZLE_PSR7_V2_MIME_FUNC = '\GuzzleHttp\Psr7\MimeType::fromFilename'; + /** * File path * @var string @@ -170,7 +173,8 @@ public function setMetaLookup(MetaLookupInterface $metaLookup, * @return string */ public function getMime(): ?string { - $mime = \GuzzleHttp\Psr7\mimetype_from_filename(basename($this->path)); + $f = function_exists(self::GUZZLE_PSR7_V1_MIME_FUNC) ? self::GUZZLE_PSR7_V1_MIME_FUNC : self::GUZZLE_PSR7_V2_MIME_FUNC; + $mime = $f(basename($this->path)); if ($mime === null) { $mime = mime_content_type($this->path); }