diff --git a/app/Foundation/Providers/AppServiceProvider.php b/app/Foundation/Providers/AppServiceProvider.php index 8b7c9757..9f3a0c21 100644 --- a/app/Foundation/Providers/AppServiceProvider.php +++ b/app/Foundation/Providers/AppServiceProvider.php @@ -14,9 +14,6 @@ namespace CachetHQ\Cachet\Foundation\Providers; use AltThree\Bus\Dispatcher; use CachetHQ\Cachet\Bus\Middleware\UseDatabaseTransactions; use CachetHQ\Cachet\Dates\DateFactory; -use CachetHQ\Cachet\Integrations\Credits; -use CachetHQ\Cachet\Integrations\Feed; -use CachetHQ\Cachet\Integrations\Releases; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; @@ -55,9 +52,6 @@ class AppServiceProvider extends ServiceProvider public function register() { $this->registerDateFactory(); - $this->registerCredits(); - $this->registerFeed(); - $this->registerReleases(); } /** @@ -74,47 +68,4 @@ class AppServiceProvider extends ServiceProvider return new DateFactory($appTimezone, $cacheTimezone); }); } - - /** - * Register the credits class. - * - * @return void - */ - protected function registerCredits() - { - $this->app->singleton(Credits::class, function ($app) { - $cache = $app['cache.store']; - - return new Credits($cache); - }); - } - - /** - * Register the feed class. - * - * @return void - */ - protected function registerFeed() - { - $this->app->singleton(Feed::class, function ($app) { - $cache = $app['cache.store']; - - return new Feed($cache); - }); - } - - /** - * Register the releases class. - * - * @return void - */ - protected function registerReleases() - { - $this->app->singleton(Releases::class, function ($app) { - $cache = $app['cache.store']; - $token = $app['config']->get('services.github.token'); - - return new Releases($cache, $token); - }); - } } diff --git a/app/Foundation/Providers/IntegrationServiceProvider.php b/app/Foundation/Providers/IntegrationServiceProvider.php index 4708ad3c..aa2c9f95 100644 --- a/app/Foundation/Providers/IntegrationServiceProvider.php +++ b/app/Foundation/Providers/IntegrationServiceProvider.php @@ -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); + }); + } } diff --git a/app/Http/Controllers/Api/GeneralController.php b/app/Http/Controllers/Api/GeneralController.php index 9036ddd2..2005560e 100644 --- a/app/Http/Controllers/Api/GeneralController.php +++ b/app/Http/Controllers/Api/GeneralController.php @@ -11,8 +11,8 @@ namespace CachetHQ\Cachet\Http\Controllers\Api; +use CachetHQ\Cachet\Integrations\Contracts\Releases; use CachetHQ\Cachet\Integrations\Contracts\System; -use CachetHQ\Cachet\Integrations\Releases; /** * This is the general api controller. @@ -38,7 +38,7 @@ class GeneralController extends AbstractApiController */ public function version() { - $latest = app(Releases::class)->latest(); + $latest = app()->make(Releases::class)->latest(); return $this->setMetaData([ 'on_latest' => version_compare(CACHET_VERSION, $latest['tag_name']) === 1, diff --git a/app/Integrations/Contracts/Credits.php b/app/Integrations/Contracts/Credits.php new file mode 100644 index 00000000..192907ca --- /dev/null +++ b/app/Integrations/Contracts/Credits.php @@ -0,0 +1,27 @@ + + */ +interface Credits +{ + /** + * Returns the latest credits. + * + * @return array|null + */ + public function latest(); +} diff --git a/app/Integrations/Contracts/Feed.php b/app/Integrations/Contracts/Feed.php new file mode 100644 index 00000000..2c7682f4 --- /dev/null +++ b/app/Integrations/Contracts/Feed.php @@ -0,0 +1,27 @@ + + */ +interface Feed +{ + /** + * Returns the latest entries. + * + * @return array|null + */ + public function latest(); +} diff --git a/app/Integrations/Contracts/Releases.php b/app/Integrations/Contracts/Releases.php new file mode 100644 index 00000000..f1526c8e --- /dev/null +++ b/app/Integrations/Contracts/Releases.php @@ -0,0 +1,27 @@ + + */ +interface Releases +{ + /** + * Returns the latest release. + * + * @return string + */ + public function latest(); +} diff --git a/app/Integrations/Credits.php b/app/Integrations/Core/Credits.php similarity index 91% rename from app/Integrations/Credits.php rename to app/Integrations/Core/Credits.php index a82105cc..f9626062 100644 --- a/app/Integrations/Credits.php +++ b/app/Integrations/Core/Credits.php @@ -9,13 +9,14 @@ * file that was distributed with this source code. */ -namespace CachetHQ\Cachet\Integrations; +namespace CachetHQ\Cachet\Integrations\Core; +use CachetHQ\Cachet\Integrations\Contracts\Credits as CreditsContract; use Exception; use GuzzleHttp\Client; use Illuminate\Contracts\Cache\Repository; -class Credits +class Credits implements CreditsContract { /** * The default url. diff --git a/app/Integrations/Feed.php b/app/Integrations/Core/Feed.php similarity index 93% rename from app/Integrations/Feed.php rename to app/Integrations/Core/Feed.php index 033839b2..824bdb20 100644 --- a/app/Integrations/Feed.php +++ b/app/Integrations/Core/Feed.php @@ -9,8 +9,9 @@ * file that was distributed with this source code. */ -namespace CachetHQ\Cachet\Integrations; +namespace CachetHQ\Cachet\Integrations\Core; +use CachetHQ\Cachet\Integrations\Contracts\Feed as FeedContract; use Exception; use GuzzleHttp\Client; use Illuminate\Contracts\Cache\Repository; @@ -20,7 +21,7 @@ use Illuminate\Contracts\Cache\Repository; * * @author James Brooks */ -class Feed +class Feed implements FeedContract { /** * The default url. diff --git a/app/Integrations/Releases.php b/app/Integrations/GitHub/Releases.php similarity index 92% rename from app/Integrations/Releases.php rename to app/Integrations/GitHub/Releases.php index bbb3bf9d..b1192723 100644 --- a/app/Integrations/Releases.php +++ b/app/Integrations/GitHub/Releases.php @@ -9,12 +9,13 @@ * file that was distributed with this source code. */ -namespace CachetHQ\Cachet\Integrations; +namespace CachetHQ\Cachet\Integrations\GitHub; +use CachetHQ\Cachet\Integrations\Contracts\Releases as ReleasesContract; use GuzzleHttp\Client; use Illuminate\Contracts\Cache\Repository; -class Releases +class Releases implements ReleasesContract { /** * The default url.