|
1
|
|
|
<?php namespace Arcanesoft\Foundation\Services\RoutesViewer; |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Contracts\Routing\Registrar as RouterContract; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class Manager |
|
7
|
|
|
* |
|
8
|
|
|
* @package Arcanesoft\Foundation\Services |
|
9
|
|
|
* @author ARCANEDEV <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class Manager |
|
12
|
|
|
{ |
|
13
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
14
|
|
|
| Properties |
|
15
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
16
|
|
|
*/ |
|
17
|
|
|
/** @var \Illuminate\Routing\Router */ |
|
18
|
|
|
protected $router; |
|
19
|
|
|
|
|
20
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
21
|
|
|
| Constructor |
|
22
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
23
|
|
|
*/ |
|
24
|
|
|
/** |
|
25
|
|
|
* Manager constructor. |
|
26
|
|
|
* |
|
27
|
|
|
* @param \Illuminate\Contracts\Routing\Registrar $router |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct(RouterContract $router) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->router = $router; |
|
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
35
|
|
|
| Main Functions |
|
36
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
37
|
|
|
*/ |
|
38
|
|
|
public function all() |
|
39
|
|
|
{ |
|
40
|
|
|
return Entities\RouteCollection::load( |
|
41
|
|
|
$this->router->getRoutes()->getRoutes(), |
|
42
|
|
|
$this->getExcludedUris(), |
|
43
|
|
|
$this->getExcludedMethods(), |
|
44
|
|
|
$this->getMethodColors() |
|
45
|
|
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getExcludedUris() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->getConfig('uris.excluded', []); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getExcludedMethods() |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->getConfig('methods.excluded', ['HEAD']); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
private function getMethodColors() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->getConfig('methods.colors', [ |
|
61
|
|
|
'GET' => 'success', |
|
62
|
|
|
'HEAD' => 'default', |
|
63
|
|
|
'POST' => 'primary', |
|
64
|
|
|
'PUT' => 'warning', |
|
65
|
|
|
'PATCH' => 'info', |
|
66
|
|
|
'DELETE' => 'danger', |
|
67
|
|
|
]); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
71
|
|
|
| Other Functions |
|
72
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getConfig($key, $default = null) |
|
75
|
|
|
{ |
|
76
|
|
|
return config("arcanesoft.foundation.routes-viewer.{$key}", $default); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..