1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-20 14:10:11 -07:00

Fix Image loaders

This commit is contained in:
David Hübner 2017-05-17 20:22:44 +02:00
parent 5c2421d5fb
commit e13c6d4324
3 changed files with 9 additions and 8 deletions

View File

@ -2,7 +2,6 @@
namespace AppBundle\Imagine; namespace AppBundle\Imagine;
use Liip\ImagineBundle\Binary\Loader\LoaderInterface; use Liip\ImagineBundle\Binary\Loader\LoaderInterface;
abstract class BaseImageLoader implements LoaderInterface abstract class BaseImageLoader implements LoaderInterface

View File

@ -57,6 +57,7 @@ class PartImageLoader extends BaseImageLoader
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e); throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
} }
return $this->mediaFilesystem->read('noimage.png'); throw new NotLoadableException(sprintf('Source image %s not found.', $path));
// return $this->mediaFilesystem->read('noimage.png');
} }
} }

View File

@ -31,16 +31,16 @@ class SetImageLoader extends BaseImageLoader
{ {
// try to load image from rebrickable website // try to load image from rebrickable website
try { try {
if ($this->remoteFileExists($this->rebrickableContext.$path)) { if ($this->remoteFileExists($this->rebrickableContext.strtolower($path))) {
return file_get_contents($this->rebrickableContext.$path); return file_get_contents($this->rebrickableContext.strtolower($path));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e); throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
} }
// Load part entity form rebrickable api and get image path from response // Load part entity form brickset api and get image path from response
try { try {
if (preg_match('/^(.*)[.png|.jpg]$/', $path, $match)) { if (preg_match('/^(.*)(.png|.jpg)$/', $path, $match)) {
$set = $this->bricksetManager->getSetByNumber($match[1]); $set = $this->bricksetManager->getSetByNumber($match[1]);
if ($set && $set->getImage()) { if ($set && $set->getImage()) {
@ -51,6 +51,7 @@ class SetImageLoader extends BaseImageLoader
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e); throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
} }
return $this->mediaFilesystem->read('noimage.png'); throw new NotLoadableException(sprintf('Source image %s not found.', $path));
// return $this->mediaFilesystem->read('noimage.png');
} }
} }