From 3be5da9176c4a5eee754562d1b525c950a10bb50 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Wed, 13 Feb 2019 12:33:44 +0100 Subject: [PATCH] Fix #75: A non existing image of an image icon throws an exception. --- CHANGELOG.md | 1 + src/Mapper/Type/ImageIconMapper.php | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bdd88a..fe55d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix ordering changes in layer control element aren't recognized ([#72](https://github.com/netzmacht/contao-leaflet-maps/issues/72)) - Fix markers with negative coordinates aren't displayed ([#74](https://github.com/netzmacht/contao-leaflet-maps/issues/74)) + - Fix image icon with non existing image throws exception ([#75])(https://github.com/netzmacht/contao-leaflet-maps/issues/75)) ## [3.1.3] - 2019-01-10 diff --git a/src/Mapper/Type/ImageIconMapper.php b/src/Mapper/Type/ImageIconMapper.php index b92e8df..11701e1 100644 --- a/src/Mapper/Type/ImageIconMapper.php +++ b/src/Mapper/Type/ImageIconMapper.php @@ -71,16 +71,10 @@ class ImageIconMapper extends AbstractIconMapper Request $request = null, $elementId = null ) { - $arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId); - - if ($model->iconImage) { - $repository = $this->repositoryManager->getRepository(FilesModel::class); - $file = $repository->findByUuid($model->iconImage); - - if ($file) { - $arguments[] = $file->path; - } - } + $arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId); + $repository = $this->repositoryManager->getRepository(FilesModel::class); + $file = $repository->findByUuid($model->iconImage); + $arguments[] = $file ? $file->path : ''; return $arguments; } @@ -117,8 +111,6 @@ class ImageIconMapper extends AbstractIconMapper $file = $repository->findByUuid($model->iconImage); if ($file) { - $definition->setIconUrl($file->path); - $file = new File($file->path); $definition->setIconSize([$file->width, $file->height]);