Tidy up integrations, use contracts

This commit is contained in:
James Brooks
2016-07-13 14:33:20 +01:00
parent ec0f0768f0
commit 503252c3a2
9 changed files with 145 additions and 57 deletions

View File

@@ -11,8 +11,14 @@
namespace CachetHQ\Cachet\Foundation\Providers;
use CachetHQ\Cachet\Integrations\Contracts\Credits as CreditsContract;
use CachetHQ\Cachet\Integrations\Contracts\Feed as FeedContract;
use CachetHQ\Cachet\Integrations\Contracts\Releases as ReleasesContract;
use CachetHQ\Cachet\Integrations\Contracts\System as SystemContract;
use CachetHQ\Cachet\Integrations\Core\Credits;
use CachetHQ\Cachet\Integrations\Core\Feed;
use CachetHQ\Cachet\Integrations\Core\System;
use CachetHQ\Cachet\Integrations\GitHub\Releases;
use Illuminate\Contracts\Container\Container;
use Illuminate\Support\ServiceProvider;
@@ -30,7 +36,39 @@ class IntegrationServiceProvider extends ServiceProvider
*/
public function register()
{
$this->registerCredits();
$this->registerFeed();
$this->registerSystem();
$this->registerReleases();
}
/**
* Register the credits class.
*
* @return void
*/
protected function registerCredits()
{
$this->app->singleton(CreditsContract::class, function ($app) {
$cache = $app['cache.store'];
return new Credits($cache);
});
}
/**
* Register the feed class.
*
* @return void
*/
protected function registerFeed()
{
$this->app->singleton(FeedContract::class, function ($app) {
$cache = $app['cache.store'];
return new Feed($cache);
});
}
/**
@@ -44,4 +82,19 @@ class IntegrationServiceProvider extends ServiceProvider
return new System();
});
}
/**
* Register the releases class.
*
* @return void
*/
protected function registerReleases()
{
$this->app->singleton(ReleasesContract::class, function ($app) {
$cache = $app['cache.store'];
$token = $app['config']->get('services.github.token');
return new Releases($cache, $token);
});
}
}