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();