Skip to content

Commit

Permalink
Merge pull request #621 from mikemand/2.0
Browse files Browse the repository at this point in the history
Allow class resolution on short name and abstract
  • Loading branch information
nWidart authored Sep 20, 2018
2 parents 85f38dc + f9ef126 commit af41b79
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/LaravelModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public function setupStubPath()
*/
protected function registerServices()
{
$this->app->singleton('modules', function ($app) {
$this->app->singleton(Contracts\RepositoryInterface::class, function ($app) {
$path = $app['config']->get('modules.paths.modules');

return new \Nwidart\Modules\Laravel\Repository($app, $path);
});
$this->app->alias(Contracts\RepositoryInterface::class, 'modules');
}
}
3 changes: 2 additions & 1 deletion src/LumenModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public function setupStubPath()
*/
protected function registerServices()
{
$this->app->singleton('modules', function ($app) {
$this->app->singleton(Contracts\RepositoryInterface::class, function ($app) {
$path = $app['config']->get('modules.paths.modules');

return new \Nwidart\Modules\Lumen\Repository($app, $path);
});
$this->app->alias(Contracts\RepositoryInterface::class, 'modules');
}
}
2 changes: 1 addition & 1 deletion src/ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ abstract protected function registerServices();
*/
public function provides()
{
return ['modules'];
return [Contracts\RepositoryInterface::class, 'modules'];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/LaravelModulesServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Nwidart\Modules\Tests;

use Nwidart\Modules\Laravel\Repository;
use Nwidart\Modules\Contracts\RepositoryInterface;

class LaravelModulesServiceProviderTest extends BaseTestCase
{
/** @test */
public function it_binds_modules_key_to_repository_class()
{
$this->assertInstanceOf(Repository::class, app('modules'));
$this->assertInstanceOf(RepositoryInterface::class, app('modules'));
}
}

0 comments on commit af41b79

Please sign in to comment.