1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Arrilot\Widgets; |
4
|
|
|
|
5
|
|
|
use Arrilot\Widgets\Console\WidgetMakeCommand; |
6
|
|
|
use Arrilot\Widgets\Factories\AsyncWidgetFactory; |
7
|
|
|
use Arrilot\Widgets\Factories\WidgetFactory; |
8
|
|
|
use Arrilot\Widgets\Misc\LaravelApplicationWrapper; |
9
|
|
|
use Illuminate\Console\AppNamespaceDetectorTrait; |
10
|
|
|
use Illuminate\Support\Facades\Blade; |
11
|
|
|
|
12
|
|
|
class ServiceProvider extends \Illuminate\Support\ServiceProvider |
13
|
|
|
{ |
14
|
|
|
use AppNamespaceDetectorTrait; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Register the service provider. |
18
|
|
|
* |
19
|
|
|
* @return void |
20
|
|
|
*/ |
21
|
|
|
public function register() |
22
|
|
|
{ |
23
|
|
|
$this->mergeConfigFrom( |
24
|
|
|
__DIR__.'/config/config.php', 'laravel-widgets' |
25
|
|
|
); |
26
|
|
|
|
27
|
|
|
$this->app->bind('arrilot.widget', function () { |
28
|
|
|
return new WidgetFactory(new LaravelApplicationWrapper()); |
29
|
|
|
}); |
30
|
|
|
|
31
|
|
|
$this->app->bind('arrilot.async-widget', function () { |
32
|
|
|
return new AsyncWidgetFactory(new LaravelApplicationWrapper()); |
33
|
|
|
}); |
34
|
|
|
|
35
|
|
|
$this->app->singleton('arrilot.widget-group-collection', function () { |
36
|
|
|
return new WidgetGroupCollection(new LaravelApplicationWrapper()); |
37
|
|
|
}); |
38
|
|
|
|
39
|
|
|
$this->app->singleton('command.widget.make', function ($app) { |
40
|
|
|
return new WidgetMakeCommand($app['files']); |
41
|
|
|
}); |
42
|
|
|
|
43
|
|
|
$this->commands('command.widget.make'); |
44
|
|
|
|
45
|
|
|
$this->app->alias('arrilot.widget', 'Arrilot\Widgets\Factories\WidgetFactory'); |
46
|
|
|
$this->app->alias('arrilot.async-widget', 'Arrilot\Widgets\Factories\AsyncWidgetFactory'); |
47
|
|
|
$this->app->alias('arrilot.widget-group-collection', 'Arrilot\Widgets\WidgetGroupCollection'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Bootstrap the application events. |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public function boot() |
56
|
|
|
{ |
57
|
|
|
$this->publishes([ |
58
|
|
|
__DIR__.'/config/config.php' => config_path('laravel-widgets.php'), |
59
|
|
|
]); |
60
|
|
|
|
61
|
|
|
$routeConfig = [ |
62
|
|
|
'namespace' => 'Arrilot\Widgets\Controllers', |
63
|
|
|
'prefix' => 'arrilot', |
64
|
|
|
'middleware' => $this->app['config']->get('laravel-widgets.route_middleware', []), |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
if (!$this->app->routesAreCached()) { |
|
|
|
|
68
|
|
|
$this->app['router']->group($routeConfig, function ($router) { |
69
|
|
|
$router->get('load-widget', 'WidgetController@showWidget'); |
70
|
|
|
}); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
Blade::directive('widget', function ($expression) { |
74
|
|
|
return "<?php echo app('arrilot.widget')->run{$expression}; ?>"; |
75
|
|
|
}); |
76
|
|
|
|
77
|
|
|
Blade::directive('asyncWidget', function ($expression) { |
78
|
|
|
return "<?php echo app('arrilot.async-widget')->run{$expression}; ?>"; |
79
|
|
|
}); |
80
|
|
|
|
81
|
|
|
Blade::directive('widgetGroup', function ($expression) { |
82
|
|
|
return "<?php echo app('arrilot.widget-group-collection')->group{$expression}->display(); ?>"; |
83
|
|
|
}); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get the services provided by the provider. |
88
|
|
|
* |
89
|
|
|
* @return array |
90
|
|
|
*/ |
91
|
|
|
public function provides() |
92
|
|
|
{ |
93
|
|
|
return ['arrilot.widget', 'arrilot.async-widget']; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.