From 193c5c1d32d258bd45a849b0614d8b25de4822d4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 9 Feb 2020 23:47:10 +0100 Subject: [PATCH] fix bug for root path --- Controller/BackendController.php | 3 ++- Models/MediaMapper.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Controller/BackendController.php b/Controller/BackendController.php index f4be1a1..38d5e92 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -24,6 +24,7 @@ use phpOMS\Contract\RenderableInterface; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Views\View; +use Modules\Media\Models\Collection; /** * Media class. @@ -134,7 +135,7 @@ final class BackendController extends Controller $media = MediaMapper::getByVirtualPath($path); $collection = CollectionMapper::getParentCollection($path); - if (!empty($collection)) { + if ($collection instanceof Collection) { $media += $collection->getSources(); /** @var string[] $glob */ diff --git a/Models/MediaMapper.php b/Models/MediaMapper.php index d75d5a0..25724b3 100644 --- a/Models/MediaMapper.php +++ b/Models/MediaMapper.php @@ -133,7 +133,7 @@ class MediaMapper extends DataMapperAbstract */ public static function getParentCollection(string $path = '/') { - $virtualPath = \substr($path, 0, \strripos($path, '/') + 1); + $virtualPath = '/' . trim(\substr($path, 0, \strripos($path, '/') + 1), '/'); $name = \substr($path, \strripos($path, '/') + 1); $query = self::getQuery();