FabricaProvider::loadViews()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Fabrica;
4
5
use App;
6
use Config;
7
use Fabrica\Facades\Fabrica as FabricaFacade;
8
use Fabrica\Services\FabricaService;
9
use Illuminate\Contracts\Events\Dispatcher;
10
11
use Illuminate\Foundation\AliasLoader;
12
use Illuminate\Routing\Router;
13
use Illuminate\Support\Collection;
14
use Illuminate\Support\Facades\View;
15
use Illuminate\Support\ServiceProvider;
16
17
use Log;
18
19
use Muleta\Traits\Providers\ConsoleTools;
20
use Route;
21
22
class FabricaProvider extends ServiceProvider
23
{
24
    use ConsoleTools;
25
26
    public $packageName = 'fabrica';
27
    const pathVendor = 'sierratecnologia/fabrica';
28
29
    public static $aliasProviders = [
30
        'Fabrica' => \Fabrica\Facades\Fabrica::class,
31
    ];
32
33
    public static $providers = [
34
35
        \Pedreiro\PedreiroServiceProvider::class,
36
37
        
38
    ];
39
40
    /**
41
     * Rotas do Menu
42
     */
43
    public static $menuItens = [
44
        // [
45
        //     'text' => 'Workspace',
46
        //     'icon' => 'fas fa-fw fa-search',
47
        //     'icon_color' => "blue",
48
        //     'label_color' => "success",
49
        //     'section'     => 'painel',
50
        //     'level'       => 1, // 0 (Public), 1, 2 (Admin) , 3 (Root)
51
        // ],
52
        // [
53
        //     'text' => 'Configurações',
54
        //     'icon' => 'fas fa-fw fa-search',
55
        //     'icon_color' => "blue",
56
        //     'label_color' => "success",
57
        //     'section'     => 'admin',
58
        //     'level'       => 1, // 0 (Public), 1, 2 (Admin) , 3 (Root)
59
        // ],
60
        'Desenvolvimento|530',
61
        // 'Workspace|5' => [
62
        //     [
63
        //         'text' => 'Desenvolvimento',
64
        //         'icon' => 'fas fa-fw fa-search',
65
        //         'icon_color' => "blue",
66
        //         'label_color' => "success",
67
        //         'section'     => 'painel',
68
        //         'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
69
        //     ],
70
            // 'Desenvolvimento' => [
71
                // [
72
                //     'text'        => 'Procurar',
73
                //     'icon'        => 'fas fa-fw fa-search',
74
                //     'icon_color'  => 'blue',
75
                //     'label_color' => 'success',
76
                //     'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
77
                //     // 'access' => \Porteiro\Models\Role::$ADMIN
78
                // ],
79
                // [
80
                //     'text'        => 'Administração',
81
                //     'icon'        => 'fas fa-fw fa-search',
82
                //     'icon_color'  => 'blue',
83
                //     'label_color' => 'success',
84
                //     'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
85
                //     // 'access' => \Porteiro\Models\Role::$ADMIN
86
                // ],
87
                // 'Procurar' => [
88
                    [
89
                        'text'        => 'Projetos',
90
                        'route'       => 'painel.fabrica.projects.index',
91
                        'icon'        => 'fas fa-fw fa-ship',
92
                        'icon_color'  => 'blue',
93
                        'label_color' => 'success',
94
                        'order' => 550,
95
                        'section'     => 'painel',
96
                        'feature' => 'fabrica',
97
                        'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
98
                        // 'access' => \Porteiro\Models\Role::$ADMIN
99
                    ],
100
                    [
101
                        'text'        => 'Issues',
102
                        'route'       => 'painel.fabrica.issues.index',
103
                        'icon'        => 'fas fa-fw fa-car',
104
                        'icon_color'  => 'blue',
105
                        'label_color' => 'success',
106
                        'order' => 550,
107
                        'section'     => 'painel',
108
                        'feature' => 'fabrica',
109
                        'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
110
                        // 'access' => \Porteiro\Models\Role::$ADMIN
111
                    ],
112
                    // ],
113
        //     ],
114
        // ],
115
        'Fabrica|2450' => [
116
            // [
117
            //     'text'        => 'Tarefas',
118
            //     'icon'        => 'fas fa-fw fa-search',
119
            //     'icon_color'  => 'blue',
120
            //     'label_color' => 'success',
121
            //     'section'     => 'admin',
122
            //     'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
123
            //     // 'access' => \Porteiro\Models\Role::$ADMIN
124
            // ],
125
            [
126
                'text'        => 'Itens',
127
                'icon'        => 'fas fa-fw fa-search',
128
                'icon_color'  => 'blue',
129
                'label_color' => 'success',
130
                'order' => 2550,
131
                'section'     => 'admin',
132
                'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
133
                // 'access' => \Porteiro\Models\Role::$ADMIN
134
            ],
135
            'Itens' => [
136
                [
137
                    'text'        => 'Stages',
138
                    'route'       => 'admin.fabrica.stages.index',
139
                    'icon'        => 'fas fa-fw fa-car',
140
                    'icon_color'  => 'blue',
141
                    'label_color' => 'success',
142
                    'order' => 2550,
143
                    'section'     => 'admin',
144
                    'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
145
                    // 'access' => \Porteiro\Models\Role::$ADMIN
146
                ],
147
                [
148
                    'text'        => 'Status',
149
                    'route'       => 'admin.fabrica.status.index',
150
                    'icon'        => 'fas fa-fw fa-car',
151
                    'icon_color'  => 'blue',
152
                    'label_color' => 'success',
153
                    'order' => 2550,
154
                    'section'     => 'admin',
155
                    'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
156
                    // 'access' => \Porteiro\Models\Role::$ADMIN
157
                ],
158
                [
159
                    'text'        => 'Resolutions',
160
                    'route'       => 'admin.fabrica.resolutions.index',
161
                    'icon'        => 'fas fa-fw fa-car',
162
                    'icon_color'  => 'blue',
163
                    'label_color' => 'success',
164
                    'order' => 2550,
165
                    'section'     => 'admin',
166
                    'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
167
                    // 'access' => \Porteiro\Models\Role::$ADMIN
168
                ],
169
            // ],
170
            // 'Tarefas' => [
171
                [
172
                    'text'        => 'Fields',
173
                    'route'       => 'admin.fabrica.fields.index',
174
                    'icon'        => 'fas fa-fw fa-car',
175
                    'icon_color'  => 'blue',
176
                    'label_color' => 'success',
177
                    'order' => 2550,
178
                    'section'     => 'admin',
179
                    'level'       => 3, // 0 (Public), 1, 2 (Admin) , 3 (Root)
180
                    // 'access' => \Porteiro\Models\Role::$ADMIN
181
                ],
182
            ],
183
        ],
184
    ];
185
186
    /**
187
     * Alias the services in the boot.
188
     */
189
    public function boot()
190
    {
191
        
192
        // Register configs, migrations, etc
193
        $this->registerDirectories();
194
195
        // COloquei no register pq nao tava reconhecendo as rotas para o adminlte
196
        $this->app->booted(
197
            function () {
198
                $this->routes();
199
            }
200
        );
201
202
        $this->loadLogger();
203
    }
204
205
    /**
206
     * Register the tool's routes.
207
     *
208
     * @return void
209
     */
210
    protected function routes()
211
    {
212
        if ($this->app->routesAreCached()) {
213
            return;
214
        }
215
216
        /**
217
         * Transmissor; Routes
218
         */
219
        $this->loadRoutesForRiCa(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'routes');
220
221
        // /**
222
        //  * Fabrica; Routes
223
        //  */
224
        // Route::group(
225
        //     [
226
        //         'namespace' => '\Fabrica\Http\Controllers',
227
        //         'prefix' => \Illuminate\Support\Facades\Config::get('application.routes.main', ''),
228
        //         'as' => 'rica.',
229
        //         // 'middleware' => 'rica',
230
        //     ], function ($router) {
231
        //         include __DIR__.'/../routes/web.php';
232
        //     }
233
        // );
234
    }
235
236
    /**
237
     * Register the services.
238
     */
239
    public function register()
240
    {
241
        $this->mergeConfigFrom($this->getPublishesPath('config'.DIRECTORY_SEPARATOR.'sitec'.DIRECTORY_SEPARATOR.'fabrica.php'), 'sitec.fabrica');
242
        
243
244
        $this->setProviders();
245
        // $this->routes();
246
247
248
249
        // Register Migrations
250
        $this->loadMigrationsFrom(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'migrations');
251
252
        $this->app->singleton(
253
            'fabrica', function () {
254
                return new Fabrica();
255
            }
256
        );
257
        
258
        /*
259
        |--------------------------------------------------------------------------
260
        | Register the Utilities
261
        |--------------------------------------------------------------------------
262
        */
263
        /**
264
         * Singleton Fabrica;
265
         */
266
        $this->app->singleton(
267
            FabricaService::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
268
                Log::channel('sitec-fabrica')->info('Singleton Fabrica;');
269
                return new FabricaService(\Illuminate\Support\Facades\Config::get('sitec.fabrica'));
270
            }
271
        );
272
273
        // Register commands
274
        $this->registerCommandFolders(
275
            [
276
            base_path('vendor/sierratecnologia/fabrica/src/Console/Commands') => '\Fabrica\Console\Commands',
277
            ]
278
        );
279
280
        // /**
281
        //  * Helpers
282
        //  */
283
        // Aqui noa funciona
284
        // if (!function_exists('fabrica_asset')) {
285
        //     function fabrica_asset($path, $secure = null)
286
        //     {
287
        //         return route('rica.fabrica.assets').'?path='.urlencode($path);
288
        //     }
289
        // }
290
    }
291
292
    /**
293
     * Get the services provided by the provider.
294
     *
295
     * @return array
296
     */
297
    public function provides()
298
    {
299
        return [
300
            'fabrica',
301
        ];
302
    }
303
304
    /**
305
     * Register configs, migrations, etc
306
     *
307
     * @return void
308
     */
309
    public function registerDirectories()
310
    {
311
        // Publish config files
312
        $this->publishes(
313
            [
314
            // Paths
315
            $this->getPublishesPath('config'.DIRECTORY_SEPARATOR.'sitec') => config_path('sitec'),
316
            ], ['config',  'sitec', 'sitec-config']
317
        );
318
319
        // // Publish fabrica css and js to public directory
320
        // $this->publishes([
321
        //     $this->getDistPath('fabrica') => public_path('assets/fabrica')
322
        // ], ['public',  'sitec', 'sitec-public']);
323
324
        $this->loadViews();
325
        $this->loadTranslations();
326
    }
327
328
    private function loadViews()
329
    {
330
        // View namespace
331
        $viewsPath = $this->getResourcesPath('views');
332
        $this->loadViewsFrom($viewsPath, 'fabrica');
333
        $this->publishes(
334
            [
335
            $viewsPath => base_path('resources'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'fabrica'),
336
            ], ['views',  'sitec', 'sitec-views']
337
        );
338
    }
339
    
340
    private function loadTranslations()
341
    {
342
        // Publish lanaguage files
343
        $this->publishes(
344
            [
345
            $this->getResourcesPath('lang') => resource_path('lang'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'fabrica')
346
            ], ['lang',  'sitec', 'sitec-lang', 'translations']
347
        );
348
349
        // Load translations
350
        $this->loadTranslationsFrom($this->getResourcesPath('lang'), 'fabrica');
351
    }
352
353
354
    /**
355
     *
356
     */
357
    private function loadLogger()
358
    {
359
        Config::set(
360
            'logging.channels.sitec-fabrica', [
361
            'driver' => 'single',
362
            'path' => storage_path('logs'.DIRECTORY_SEPARATOR.'sitec-fabrica.log'),
363
            'level' => env('APP_LOG_LEVEL', 'debug'),
364
            ]
365
        );
366
    }
367
}
368