1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spinen\ClickUp\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Config; |
6
|
|
|
use Illuminate\Support\Facades\Route; |
7
|
|
|
use Illuminate\Support\ServiceProvider as LaravelServiceProvider; |
8
|
|
|
use Spinen\ClickUp\Http\Middleware\Filter; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class ServiceProvider |
12
|
|
|
* |
13
|
|
|
* @package Spinen\ClickUp\Providers |
14
|
|
|
*/ |
15
|
|
|
class ServiceProvider extends LaravelServiceProvider |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Bootstrap services. |
19
|
|
|
* |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
|
|
public function boot() |
23
|
|
|
{ |
24
|
|
|
$this->registerMiddleware(); |
25
|
|
|
|
26
|
|
|
$this->registerPublishes(); |
27
|
|
|
|
28
|
|
|
$this->registerRoutes(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Register services. |
33
|
|
|
* |
34
|
|
|
* @return void |
35
|
|
|
*/ |
36
|
|
|
public function register() |
37
|
|
|
{ |
38
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../../config/clickup.php', 'clickup'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Register the middleware |
43
|
|
|
* |
44
|
|
|
* If a route needs to have the QuickBooks client, then make sure that the user has linked their account. |
45
|
|
|
* |
46
|
|
|
*/ |
47
|
|
|
public function registerMiddleware() |
48
|
|
|
{ |
49
|
|
|
$this->app->router->aliasMiddleware('clickup', Filter::class); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* There are several resources that get published |
54
|
|
|
* |
55
|
|
|
* Only worry about telling the application about them if running in the console. |
56
|
|
|
*/ |
57
|
|
|
protected function registerPublishes() |
58
|
|
|
{ |
59
|
|
|
if ($this->app->runningInConsole()) { |
60
|
|
|
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); |
61
|
|
|
|
62
|
|
|
$this->publishes( |
63
|
|
|
[ |
64
|
|
|
__DIR__ . '/../../config/clickup.php' => config_path('clickup.php'), |
65
|
|
|
], |
66
|
|
|
'clickup-config' |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
$this->publishes( |
70
|
|
|
[ |
71
|
|
|
__DIR__ . '/../../database/migrations' => database_path('migrations'), |
72
|
|
|
], |
73
|
|
|
'clickup-migrations' |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Register the routes needed for the OAuth flow |
80
|
|
|
*/ |
81
|
|
|
protected function registerRoutes() |
82
|
|
|
{ |
83
|
|
|
if (Config::get('clickup.route.enabled')) { |
84
|
|
|
Route::group( |
85
|
|
|
[ |
86
|
|
|
'namespace' => 'Spinen\ClickUp\Http\Controllers', |
87
|
|
|
'middleware' => Config::get('clickup.route.middleware', ['web']), |
88
|
|
|
], |
89
|
|
|
function () { |
90
|
|
|
$this->loadRoutesFrom(realpath(__DIR__ . '/../../routes/web.php')); |
91
|
|
|
} |
92
|
|
|
); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|