phpstan fixes

This commit is contained in:
Dennis Eichhorn 2020-02-09 16:08:27 +01:00
parent 5439e1ba11
commit 2f45bf318b
2 changed files with 8 additions and 4 deletions

View File

@ -128,18 +128,22 @@ final class BackendController extends Controller
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Media/Theme/Backend/media-list');
$path = (string) ($request->getData('path') ?? '/');
$path = (string) ($request->getData('path') ?? '/');
/** @var Media[] $media */
$media = MediaMapper::getByVirtualPath($path);
$collection = CollectionMapper::getParentCollection($path);
if (!empty($collection)) {
$media += $collection->getSources();
/** @var string[] $glob */
$glob = \glob(__DIR__ . '/../Files' . \trim($collection->getPath(), '/') . '/' . $collection->getName() . '/*');
$glob = $glob === false ? [] : $glob;
foreach ($glob as $file) {
foreach ($media as $obj) {
if ($obj->getName() . '.' . $obj->getExtension() === \basename($file)){
if ($obj->getName() . '.' . $obj->getExtension() === \basename($file)) {
continue 2;
}
}
@ -148,7 +152,7 @@ final class BackendController extends Controller
$localMedia = new Media();
$localMedia->setName($pathinfo['filename']);
$localMedia->setExtension($pathinfo['extension']);
$localMedia->setExtension($pathinfo['extension'] ?? '');
$localMedia->setCreatedBy(new Account());
$media[] = $localMedia;

View File

@ -104,7 +104,7 @@ class MediaMapper extends DataMapperAbstract
* path if so desired without deleting or moving the orginal media files.
*
* @param string $virtualPath Virtual path
* @param string $hidden Get hidden files
* @param bool $hidden Get hidden files
*
* @return array
*