diff --git a/app/Foundation/Providers/AppServiceProvider.php b/app/Foundation/Providers/AppServiceProvider.php index 387ec0c9..c6dcc1e0 100644 --- a/app/Foundation/Providers/AppServiceProvider.php +++ b/app/Foundation/Providers/AppServiceProvider.php @@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Foundation\Providers; use AltThree\Bus\Dispatcher; use CachetHQ\Cachet\Bus\Middleware\UseDatabaseTransactions; use CachetHQ\Cachet\Dates\DateFactory; +use CachetHQ\Cachet\GitHub\Release; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; @@ -52,6 +53,7 @@ class AppServiceProvider extends ServiceProvider public function register() { $this->registerDateFactory(); + $this->registerRelease(); } /** @@ -62,10 +64,25 @@ class AppServiceProvider extends ServiceProvider protected function registerDateFactory() { $this->app->singleton(DateFactory::class, function ($app) { - $appTimezone = $app->config->get('app.timezone'); - $cacheTimezone = $app->config->get('cachet.timezone'); + $appTimezone = $app['config']->get('app.timezone'); + $cacheTimezone = $app['config']->get('cachet.timezone'); return new DateFactory($appTimezone, $cacheTimezone); }); } + + /** + * Register the releases class. + * + * @return void + */ + protected function registerRelease() + { + $this->app->singleton(Release::class, function ($app) { + $cache = $app['cache.store']; + $token = $app['config']->get('services.github.token') + + return new Release($cache, $token); + }); + } } diff --git a/app/Foundation/Providers/GitHubServiceProvider.php b/app/Foundation/Providers/GitHubServiceProvider.php deleted file mode 100644 index 0bb80130..00000000 --- a/app/Foundation/Providers/GitHubServiceProvider.php +++ /dev/null @@ -1,45 +0,0 @@ -registerRelease(); - } - - /** - * Register the releases class. - * - * @return void - */ - protected function registerRelease() - { - $this->app->singleton('cachet.release', function ($app) { - $cache = $app['cache.store']; - $config = $app['config']; - - return new Release($cache, $config); - }); - - $this->app->alias('cachet.release', Release::class); - } -} diff --git a/app/GitHub/Release.php b/app/GitHub/Release.php index 6fe0de8d..583bb26f 100644 --- a/app/GitHub/Release.php +++ b/app/GitHub/Release.php @@ -13,7 +13,6 @@ namespace CachetHQ\Cachet\GitHub; use GuzzleHttp\Client; use Illuminate\Contracts\Cache\Repository as CacheRepository; -use Illuminate\Contracts\Config\Repository as ConfigRepository; class Release { @@ -25,24 +24,24 @@ class Release protected $cache; /** - * The config repository instance. + * The github authentication token. * - * @var \Illuminate\Contracts\Config\Repository + * @var string */ - protected $config; + protected $token; /** * Creates a new release instance. * - * @param \Illuminate\Contracts\Cache\Repository $cache - * @param \Illuminate\Contracts\Config\Repository $config + * @param \Illuminate\Contracts\Cache\Repository $cache + * @param string $token * * @return void */ - public function __construct(CacheRepository $cache, ConfigRepository $config) + public function __construct(CacheRepository $cache, $token) { $this->cache = $cache; - $this->config = $config; + $this->token = $token; } /** @@ -56,8 +55,8 @@ class Release $headers = ['Accept' => 'application/vnd.github.v3+json']; // We can re-use the Emoji token here, if we have it. - if ($token = $this->config->get('services.github.token')) { - $headers['OAUTH-TOKEN'] = $token; + if ($this->token) { + $headers['OAUTH-TOKEN'] = $this->token; } return json_decode((new Client())->get('https://api.github.com/repos/cachethq/cachet/releases/latest', [ diff --git a/config/app.php b/config/app.php index ad28809c..8d00d1e2 100644 --- a/config/app.php +++ b/config/app.php @@ -184,7 +184,6 @@ return [ 'CachetHQ\Cachet\Foundation\Providers\ConsoleServiceProvider', 'CachetHQ\Cachet\Foundation\Providers\ConfigServiceProvider', 'CachetHQ\Cachet\Foundation\Providers\EventServiceProvider', - 'CachetHQ\Cachet\Foundation\Providers\GitHubServiceProvider', 'CachetHQ\Cachet\Foundation\Providers\RepositoryServiceProvider', 'CachetHQ\Cachet\Foundation\Providers\RouteServiceProvider',