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