Page MenuHomeDevCentral

DockerHubServiceProvider.php
No OneTemporary

DockerHubServiceProvider.php

<?php
namespace Nasqueron\Notifications\Providers;
use Keruald\DockerHub\Build\TriggerBuildFactory;
use GuzzleHttp\Client;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
class DockerHubServiceProvider extends ServiceProvider {
/**
* Bootstraps the application services.
*/
public function boot() : void {
}
/**
* Gets the tokens to trigger build for the Docker Hub images.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return array
*/
public static function getTokens (Application $app) : array {
$file = $app->make('config')->get('services.dockerhub.tokens');
$fs = $app->make('filesystem')->disk('local');
if ($fs->exists($file)) {
$content = $fs->get($file);
return json_decode($content, true);
}
return [];
}
/**
* Registers the application services.
*/
public function register() : void {
$this->app->singleton('dockerhub', function (Application $app) {
$tokens = DockerHubServiceProvider::getTokens($app);
return new TriggerBuildFactory(new Client, $tokens);
});
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Nov 28, 17:44 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3209086
Default Alt Text
DockerHubServiceProvider.php (1 KB)

Event Timeline