Skip to content

Commit

Permalink
Updating the service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Dec 19, 2016
1 parent 46412de commit 7d7c011
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"require": {
"php": ">=5.6.4",
"arcanedev/support": "~3.0",
"arcanedev/support": "~3.20",
"guzzlehttp/guzzle": "~5.0|~6.0"
},
"require-dev": {
Expand Down
14 changes: 2 additions & 12 deletions src/GeoIPServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ public function register()
$this->registerGeoIpManager();
$this->registerGeoIpCache();
$this->registerGeoIp();

if ($this->app->runningInConsole()) {
$this->commands([
Console\ClearCommand::class,
Console\UpdateCommand::class,
]);
}
$this->registerConsoleServiceProvider(Providers\CommandServiceProvider::class);
}

/**
Expand All @@ -90,9 +84,6 @@ public function provides()
Contracts\GeoIPDriver::class,
Contracts\GeoIPCache::class,
Contracts\DriverFactory::class,

Console\ClearCommand::class,
Console\UpdateCommand::class,
];
}

Expand All @@ -106,7 +97,6 @@ public function provides()
private function registerGeoIpManager()
{
$this->singleton(Contracts\DriverFactory::class, DriverManager::class);

$this->singleton(Contracts\GeoIPDriver::class, function ($app) {
return $app[Contracts\DriverFactory::class]->driver();
});
Expand Down Expand Up @@ -145,6 +135,6 @@ private function registerGeoIp()
);
});

$this->bind('arcanedev.geoip', Contracts\GeoIP::class);
$this->singleton('arcanedev.geoip', Contracts\GeoIP::class);
}
}
27 changes: 27 additions & 0 deletions src/Providers/CommandServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php namespace Arcanedev\GeoIP\Providers;

use Arcanedev\GeoIP\Console;
use Arcanedev\Support\Providers\CommandServiceProvider as ServiceProvider;

/**
* Class CommandServiceProvider
*
* @package Arcanedev\GeoIP\Providers
* @author ARCANEDEV <[email protected]>
*/
class CommandServiceProvider extends ServiceProvider
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* The commands to be registered.
*
* @var array
*/
protected $commands = [
Console\ClearCommand::class,
Console\UpdateCommand::class,
];
}
3 changes: 0 additions & 3 deletions tests/GeoIPServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ public function it_can_provides()
\Arcanedev\GeoIP\Contracts\GeoIPDriver::class,
\Arcanedev\GeoIP\Contracts\GeoIPCache::class,
\Arcanedev\GeoIP\Contracts\DriverFactory::class,

\Arcanedev\GeoIP\Console\ClearCommand::class,
\Arcanedev\GeoIP\Console\UpdateCommand::class,
];

$this->assertSame($expected, $this->provider->provides());
Expand Down

0 comments on commit 7d7c011

Please sign in to comment.