1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jumilla\Addomnipot\Laravel\Support; |
4
|
|
|
|
5
|
|
|
use Illuminate\Routing\Router; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
abstract class RouteServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Bootstrap any application services. |
12
|
|
|
* |
13
|
|
|
* @param \Illuminate\Routing\Router $router |
|
|
|
|
14
|
|
|
* @return void |
15
|
|
|
*/ |
16
|
|
|
public function boot() |
17
|
|
|
{ |
18
|
|
|
$this->app->call([$this, 'map']); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Define the routes for the addon. |
23
|
|
|
* |
24
|
|
|
* @param \Illuminate\Routing\Router $router (injection) |
25
|
|
|
* @return void |
26
|
|
|
*/ |
27
|
|
|
public function map(Router $router) |
28
|
|
|
{ |
29
|
|
|
$addon = $this->addon(); |
30
|
|
|
$config = $addon->config('addon.routes'); |
31
|
|
|
|
32
|
|
|
$attributes = [ |
33
|
|
|
'domain' => array_get($config, 'domain', null), |
34
|
|
|
'prefix' => array_get($config, 'prefix', ''), |
35
|
|
|
'namespace' => array_get($config, 'namespace', $addon->phpNamespace().'\\Controllers'), |
36
|
|
|
'middleware' => array_get($config, 'middleware', []), |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
$files = array_map(function ($file) use ($addon) { |
40
|
|
|
return $addon->path($file); |
41
|
|
|
}, array_get($config, 'files', ['classes/Http/routes.php'])); |
42
|
|
|
|
43
|
|
|
$router->group($attributes, function ($router) use ($files) { |
44
|
|
|
foreach ($files as $file) { |
45
|
|
|
require $file; |
46
|
|
|
} |
47
|
|
|
}); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get addon. |
52
|
|
|
* |
53
|
|
|
* @return \Jumilla\Addomnipot\Laravel\Addon |
54
|
|
|
*/ |
55
|
|
|
abstract protected function addon(); |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Register the service provider. |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function register() |
63
|
|
|
{ |
64
|
|
|
// |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Pass dynamic methods onto the router instance. |
69
|
|
|
* |
70
|
|
|
* @param string $method |
71
|
|
|
* @param array $parameters |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
|
|
public function __call($method, $parameters) |
75
|
|
|
{ |
76
|
|
|
return call_user_func_array([$this->app->make(Router::class), $method], $parameters); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.