1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Transmissor; |
4
|
|
|
|
5
|
|
|
use App; |
6
|
|
|
use Config; |
7
|
|
|
use Illuminate\Contracts\Events\Dispatcher; |
8
|
|
|
use Illuminate\Contracts\Http\Kernel; |
9
|
|
|
use Illuminate\Foundation\AliasLoader; |
10
|
|
|
|
11
|
|
|
use Illuminate\Routing\Router; |
12
|
|
|
use Illuminate\Support\Collection; |
13
|
|
|
use Illuminate\Support\Facades\View; |
14
|
|
|
use Illuminate\Support\ServiceProvider; |
15
|
|
|
use Log; |
16
|
|
|
|
17
|
|
|
use Muleta\Traits\Providers\ConsoleTools; |
18
|
|
|
|
19
|
|
|
use Route; |
20
|
|
|
|
21
|
|
|
use Transmissor\Facades\Transmissor as TransmissorFacade; |
22
|
|
|
use Transmissor\Observers\TransmissorCallbacks; |
23
|
|
|
use Transmissor\Services\TransmissorService; |
24
|
|
|
|
25
|
|
|
class TransmissorProvider extends ServiceProvider |
26
|
|
|
{ |
27
|
|
|
use ConsoleTools; |
28
|
|
|
|
29
|
|
|
public $packageName = 'transmissor'; |
30
|
|
|
const pathVendor = 'sierratecnologia/transmissor'; |
31
|
|
|
|
32
|
|
|
public static $aliasProviders = [ |
33
|
|
|
'Transmissor' => \Transmissor\Facades\Transmissor::class, |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
public static $providers = [ |
37
|
|
|
|
38
|
|
|
// \Support\SupportProviderService::class, |
39
|
|
|
\Telefonica\TelefonicaProvider::class, |
40
|
|
|
\Transmissor\Providers\NotificationServiceProvider::class, |
41
|
|
|
\Transmissor\Providers\ActivityServiceProvider::class, |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
]; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Rotas do Menu |
48
|
|
|
*/ |
49
|
|
|
public static $menuItens = [ |
50
|
|
|
'Admin' => [ |
51
|
|
|
[ |
52
|
|
|
'text' => 'Notifications', |
53
|
|
|
'route' => 'admin.transmissor.notifications.index', |
54
|
|
|
'icon' => 'puzzle-piece', |
55
|
|
|
'section' => 'painel', |
56
|
|
|
'level' => 3, |
57
|
|
|
], |
58
|
|
|
], |
59
|
|
|
]; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Alias the services in the boot. |
63
|
|
|
*/ |
64
|
|
|
public function boot() |
65
|
|
|
{ |
66
|
|
|
|
67
|
|
|
// Register configs, migrations, etc |
68
|
|
|
$this->registerDirectories(); |
69
|
|
|
|
70
|
|
|
// COloquei no register pq nao tava reconhecendo as rotas para o adminlte |
71
|
|
|
$this->app->booted( |
72
|
|
|
function () { |
73
|
|
|
$this->routes(); |
74
|
|
|
} |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
$this->loadLogger(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Register the tool's routes. |
82
|
|
|
* |
83
|
|
|
* @return void |
84
|
|
|
*/ |
85
|
|
|
protected function routes() |
86
|
|
|
{ |
87
|
|
|
if ($this->app->routesAreCached()) { |
88
|
|
|
return; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Transmissor; Routes |
93
|
|
|
*/ |
94
|
|
|
$this->loadRoutesForRiCa(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'routes'); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Register the services. |
99
|
|
|
*/ |
100
|
|
|
public function register() |
101
|
|
|
{ |
102
|
|
|
$this->mergeConfigFrom($this->getPublishesPath('config'.DIRECTORY_SEPARATOR.'sitec'.DIRECTORY_SEPARATOR.'transmissor.php'), 'sitec.transmissor'); |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
$this->setProviders(); |
106
|
|
|
|
107
|
|
|
// $kernel = $this->app->make(Kernel::class); |
108
|
|
|
// $kernel->pushMiddleware(TransmissorCallbacks::class); |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
// Register Migrations |
112
|
|
|
$this->loadMigrationsFrom(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'migrations'); |
113
|
|
|
|
114
|
|
|
$this->app->singleton( |
115
|
|
|
'transmissor', |
116
|
|
|
function () { |
117
|
|
|
return new Transmissor(); |
118
|
|
|
} |
119
|
|
|
); |
120
|
|
|
|
121
|
|
|
/* |
122
|
|
|
|-------------------------------------------------------------------------- |
123
|
|
|
| Register the Utilities |
124
|
|
|
|-------------------------------------------------------------------------- |
125
|
|
|
*/ |
126
|
|
|
/** |
127
|
|
|
* Singleton Transmissor; |
128
|
|
|
*/ |
129
|
|
|
$this->app->singleton( |
130
|
|
|
TransmissorService::class, |
131
|
|
|
function ($app) { |
|
|
|
|
132
|
|
|
Log::channel('sitec-transmissor')->info('Singleton Transmissor;'); |
133
|
|
|
return new TransmissorService(\Illuminate\Support\Facades\Config::get('sitec.transmissor')); |
134
|
|
|
} |
135
|
|
|
); |
136
|
|
|
|
137
|
|
|
// Register commands |
138
|
|
|
$this->registerCommandFolders( |
139
|
|
|
[ |
140
|
|
|
base_path('vendor/sierratecnologia/transmissor/src/Console/Commands') => '\Transmissor\Console\Commands', |
141
|
|
|
] |
142
|
|
|
); |
143
|
|
|
|
144
|
|
|
// /** |
145
|
|
|
// * Helpers |
146
|
|
|
// */ |
147
|
|
|
// Aqui noa funciona |
148
|
|
|
// if (!function_exists('transmissor_asset')) { |
149
|
|
|
// function transmissor_asset($path, $secure = null) |
150
|
|
|
// { |
151
|
|
|
// return route('rica.transmissor.assets').'?path='.urlencode($path); |
152
|
|
|
// } |
153
|
|
|
// } |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Get the services provided by the provider. |
158
|
|
|
* |
159
|
|
|
* @return array |
160
|
|
|
*/ |
161
|
|
|
public function provides() |
162
|
|
|
{ |
163
|
|
|
return [ |
164
|
|
|
'transmissor', |
165
|
|
|
]; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Register configs, migrations, etc |
170
|
|
|
* |
171
|
|
|
* @return void |
172
|
|
|
*/ |
173
|
|
|
public function registerDirectories() |
174
|
|
|
{ |
175
|
|
|
// Publish config files |
176
|
|
|
$this->publishes( |
177
|
|
|
[ |
178
|
|
|
// Paths |
179
|
|
|
$this->getPublishesPath('config'.DIRECTORY_SEPARATOR.'sitec') => config_path('sitec'), |
180
|
|
|
], |
181
|
|
|
['config', 'sitec', 'sitec-config'] |
182
|
|
|
); |
183
|
|
|
|
184
|
|
|
// // Publish transmissor css and js to public directory |
185
|
|
|
// $this->publishes([ |
186
|
|
|
// $this->getDistPath('transmissor') => public_path('assets/transmissor') |
187
|
|
|
// ], ['public', 'sitec', 'sitec-public']); |
188
|
|
|
|
189
|
|
|
$this->loadViews(); |
190
|
|
|
$this->loadTranslations(); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
private function loadViews() |
194
|
|
|
{ |
195
|
|
|
// View namespace |
196
|
|
|
$viewsPath = $this->getResourcesPath('views'); |
197
|
|
|
$this->loadViewsFrom($viewsPath, 'transmissor'); |
198
|
|
|
$this->publishes( |
199
|
|
|
[ |
200
|
|
|
$viewsPath => base_path('resources'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'transmissor'), |
201
|
|
|
], |
202
|
|
|
['views', 'sitec', 'sitec-views'] |
203
|
|
|
); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
private function loadTranslations() |
207
|
|
|
{ |
208
|
|
|
// Publish lanaguage files |
209
|
|
|
$this->publishes( |
210
|
|
|
[ |
211
|
|
|
$this->getResourcesPath('lang') => resource_path('lang'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'transmissor') |
212
|
|
|
], |
213
|
|
|
['lang', 'sitec', 'sitec-lang', 'translations'] |
214
|
|
|
); |
215
|
|
|
|
216
|
|
|
// Load translations |
217
|
|
|
$this->loadTranslationsFrom($this->getResourcesPath('lang'), 'transmissor'); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* |
223
|
|
|
*/ |
224
|
|
|
private function loadLogger() |
225
|
|
|
{ |
226
|
|
|
Config::set( |
227
|
|
|
'logging.channels.sitec-transmissor', |
228
|
|
|
[ |
229
|
|
|
'driver' => 'single', |
230
|
|
|
'path' => storage_path('logs'.DIRECTORY_SEPARATOR.'sitec-transmissor.log'), |
231
|
|
|
'level' => env('APP_LOG_LEVEL', 'debug'), |
232
|
|
|
] |
233
|
|
|
); |
234
|
|
|
} |
235
|
|
|
} |
236
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.