Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Apr 17, 2021
1 parent 3a0e315 commit edace36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: crynobone
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
liberapay: crynobone
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["https://paypal.me/crynobone"]
17 changes: 9 additions & 8 deletions src/ImagineServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ class ImagineServiceProvider extends ServiceProvider implements DeferrableProvid
public function register()
{
$this->app->singleton('orchestra.imagine', function (Container $app) {
$manager = new ImagineManager($app);
$namespace = $this->hasPackageRepository() ? 'orchestra/imagine::' : 'orchestra.imagine';

$manager->setConfiguration($app->make('config')->get($namespace));

return $manager;
return new ImagineManager($app);
});

$this->registerCoreContainerAliases();
}

/**
* Register the core class aliases in the container.
*/
protected function registerCoreContainerAliases(): void
{
$this->callAfterResolving('orchestra.imagine', function ($manager, $app) {
$namespace = $this->hasPackageRepository() ? 'orchestra/imagine::' : 'orchestra.imagine';

$manager->setConfiguration($app->make('config')->get($namespace));
});

$this->app->alias('orchestra.imagine', ImagineManager::class);

$this->app->bind(ImagineInterface::class, static function (Container $app) {
Expand All @@ -54,6 +53,8 @@ public function boot()
if (! $this->hasPackageRepository()) {
$this->bootUsingLaravel($path);
}

$this->registerCoreContainerAliases();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/ImagineServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ public function it_provides_expected_services()

public function usesGdDriver($app)
{
$app['config']->set('orchestra.imagine', ['driver' => 'gd']);
$app['orchestra.imagine']->setDefaultDriver('driver', 'gd');
}

public function usesImagickDriver($app)
{
$app['config']->set('orchestra.imagine', ['driver' => 'imagick']);
$app['orchestra.imagine']->setDefaultDriver('driver', 'imagick');
}

public function usesGmagickDriver($app)
{
$app['config']->set('orchestra.imagine', ['driver' => 'gmagick']);
$app['orchestra.imagine']->setDefaultDriver('driver', 'gmagick');
}
}

0 comments on commit edace36

Please sign in to comment.