laravel-connect/src/ConnectServiceProvider.php

56 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2020-05-11 16:26:34 +02:00
<?php
namespace Bluesquare\Connect;
2022-05-18 17:40:18 +02:00
use Bluesquare\Connect\Commands\RefreshTokens;
2020-05-12 15:57:23 +02:00
use Bluesquare\Connect\Commands\Sync;
2020-05-11 16:26:34 +02:00
use Illuminate\Support\ServiceProvider;
class ConnectServiceProvider extends ServiceProvider
{
public function register()
{
$this->mergeConfigFrom($this->path('config/bconnect.php'), 'bconnect');
2020-05-12 15:57:23 +02:00
2020-05-11 16:26:34 +02:00
$this->app->singleton(Connect::class, function ($app) {
return new Connect($app);
});
}
public function boot()
{
$config_path = $this->path('config/bconnect.php');
2022-05-18 17:40:18 +02:00
$views_path = $this->path('resources/views/connect');
2020-05-12 15:57:23 +02:00
2020-05-11 16:26:34 +02:00
$this->publishes([
2022-05-18 17:40:18 +02:00
$config_path => config_path('bconnect.php'),
$views_path => resource_path('views/vendor/connect'),
2020-05-12 15:57:23 +02:00
]);
2022-05-18 17:40:18 +02:00
$this->loadTranslationsFrom($this->path('resources/translations'), 'connect');
2020-05-12 15:57:23 +02:00
2022-05-18 17:40:18 +02:00
$this->loadViewsFrom($this->path('resources/views/connect'), 'connect');
2020-05-12 15:57:23 +02:00
2022-05-18 17:40:18 +02:00
if ($this->app->runningInConsole()) {
$this->commands([
RefreshTokens::class,
Sync::class,
]);
}
2020-05-12 15:57:23 +02:00
2022-05-18 17:40:18 +02:00
// Laravel 7+
2020-05-13 13:15:20 +02:00
if (method_exists($this, 'loadViewComponentsAs')) {
$this->loadViewComponentsAs('connect', [
\Bluesquare\Connect\View\Components\Button::class
]);
}
2022-05-18 17:40:18 +02:00
}
2020-05-12 15:57:23 +02:00
2022-05-18 17:40:18 +02:00
// Misc
2020-05-12 15:57:23 +02:00
2022-05-18 17:40:18 +02:00
private function path($path = '')
{
return __DIR__ . "/../$path";
2020-05-11 16:26:34 +02:00
}
}