52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Services\Graph\GraphClientInterface;
|
|
use App\Services\Graph\MicrosoftGraphClient;
|
|
use App\Services\Graph\NullGraphClient;
|
|
use App\Services\Intune\CompliancePolicyNormalizer;
|
|
use App\Services\Intune\DeviceConfigurationPolicyNormalizer;
|
|
use App\Services\Intune\SettingsCatalogPolicyNormalizer;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(GraphClientInterface::class, function ($app) {
|
|
$config = $app['config']->get('graph');
|
|
|
|
$hasCredentials = ! empty($config['client_id'])
|
|
&& ! empty($config['client_secret'])
|
|
&& ! empty($config['tenant_id']);
|
|
|
|
if (! empty($config['enabled']) && $hasCredentials) {
|
|
return $app->make(MicrosoftGraphClient::class);
|
|
}
|
|
|
|
return $app->make(NullGraphClient::class);
|
|
});
|
|
|
|
$this->app->tag(
|
|
[
|
|
CompliancePolicyNormalizer::class,
|
|
DeviceConfigurationPolicyNormalizer::class,
|
|
SettingsCatalogPolicyNormalizer::class,
|
|
],
|
|
'policy-type-normalizers'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
//
|
|
}
|
|
}
|