Skip to content

Commit

Permalink
Merge pull request #351 from plank/fix-image-manipulator-binding
Browse files Browse the repository at this point in the history
move ImageManipulator singleton to lazy instantiation
  • Loading branch information
frasmage authored Apr 9, 2024
2 parents 9cfecc7 + 2eee944 commit e1222e3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/MediableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

use CreateMediableTables;
use Illuminate\Contracts\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Filesystem\FilesystemManager;
use Illuminate\Support\ServiceProvider;
use Intervention\Image\ImageManager;
use Mimey\MimeTypes;
use Plank\Mediable\Commands\ImportMediaCommand;
use Plank\Mediable\Commands\PruneMediaCommand;
Expand Down Expand Up @@ -188,7 +191,13 @@ public function registerUrlGeneratorFactory(): void

public function registerImageManipulator(): void
{
$this->app->singleton(ImageManipulator::class);
$this->app->singleton(ImageManipulator::class, function (Container $app) {
return new ImageManipulator(
$app->get(ImageManager::class),
$app->get(FilesystemManager::class),
$app->get(ImageOptimizer::class)
);
});
}

/**
Expand Down

0 comments on commit e1222e3

Please sign in to comment.