fix bug for root path

This commit is contained in:
Dennis Eichhorn 2020-02-09 23:47:10 +01:00
parent 2f45bf318b
commit 193c5c1d32
2 changed files with 3 additions and 2 deletions

View File

@ -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 */

View File

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