Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit a00233e5 authored by Nicolas's avatar Nicolas
Browse files

Ajout de try catch

parent a6b222f7
No related branches found
No related tags found
No related merge requests found
...@@ -163,45 +163,53 @@ class ImageSlider extends Template implements BlockInterface ...@@ -163,45 +163,53 @@ class ImageSlider extends Template implements BlockInterface
} }
/** /**
* Get Slider
*
* @return array * @return array
* @throws LocalizedException
* @throws NoSuchEntityException
*/ */
public function getSlider() public function getSlider()
{ {
/** @var ImageSliderModel $slider */ try {
$slider = $this->imageSliderRepository->getById($this->getId()); /** @var ImageSliderModel $slider */
$slider = $this->imageSliderRepository->getById($this->getId());
$array = explode('|', $slider->getContent()); $array = explode('|', $slider->getContent());
$array = array_map('intval', $array); $array = array_map('intval', $array);
$result = array(); $result = array();
foreach ($array as $image) { foreach ($array as $image) {
array_push($result, $this->getImage((int)$image)); array_push($result, $this->getImage((int)$image));
} }
return $result; return $result;
} catch (LocalizedException $e) {
return null;
}
} }
/** /**
* @param $id * Get Image
*
* @param int $id
* @return array * @return array
* @throws NoSuchEntityException
* @throws LocalizedException
*/ */
private function getImage (int $id) private function getImage (int $id)
{ {
/** @var ImageModel $image */ try {
$image = $this->imageRepository->getById($id); /** @var ImageModel $image */
$image = $this->imageRepository->getById($id);
$result = array();
$result['id'] = $image->getId(); $result = array();
$result['path'] = $image->getPath(); $result['id'] = $image->getId();
$result['alt'] = $image->getAlt(); $result['path'] = $image->getPath();
$result['is_active'] = $image->isActive(); $result['alt'] = $image->getAlt();
$result['is_active'] = $image->isActive();
return $result;
return $result;
} catch (LocalizedException $e) {
return null;
}
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment