@@ -111,7 +111,7 @@ |
||
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Creates the widget class. |
114 | - * @return bool |
|
114 | + * @return false|null |
|
115 | 115 | */ |
116 | 116 | private function makeWidgetClass() |
117 | 117 | { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $this->makeWidgetClass(); |
38 | 38 | |
39 | - if (! $this->option('plain')) { |
|
39 | + if (!$this->option('plain')) { |
|
40 | 40 | $this->createView(); |
41 | 41 | } |
42 | 42 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $path = $this->getViewPath(); |
52 | 52 | |
53 | 53 | if ($this->files->exists($path)) { |
54 | - $this->error($this->qualifyClass($this->getNameInput()).'View.blade.php - Already exists! (@_@)'); |
|
54 | + $this->error($this->qualifyClass($this->getNameInput()) . 'View.blade.php - Already exists! (@_@)'); |
|
55 | 55 | |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | 59 | $this->files->put($path, $this->getViewStub()); |
60 | 60 | |
61 | - $this->info(' - '.$this->qualifyClass($this->getNameInput()).'View.blade.php - was created. (^_^)'); |
|
61 | + $this->info(' - ' . $this->qualifyClass($this->getNameInput()) . 'View.blade.php - was created. (^_^)'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $stubName = $this->option('plain') ? 'widget_plain' : 'widget'; |
72 | 72 | |
73 | - return __DIR__."/../stubs/$stubName.stub"; |
|
73 | + return __DIR__ . "/../stubs/$stubName.stub"; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected function getDefaultNamespace($rootNamespace) |
84 | 84 | { |
85 | - return $rootNamespace.'\\Widgets'; |
|
85 | + return $rootNamespace . '\\Widgets'; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | // to create the class and overwrite the user's code. So, we will bail out so the |
124 | 124 | // code is untouched. Otherwise, we will continue generating this class' files. |
125 | 125 | if ($this->alreadyExists($this->getNameInput())) { |
126 | - $this->error($this->qualifyClass($this->getNameInput()).'.php - Already exists (@_@)'); |
|
126 | + $this->error($this->qualifyClass($this->getNameInput()) . '.php - Already exists (@_@)'); |
|
127 | 127 | |
128 | 128 | return false; |
129 | 129 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | $this->files->put($path, $this->buildClass($name)); |
137 | 137 | |
138 | - $this->info(' - '.$name.'.php - was created. (^_^)'); |
|
138 | + $this->info(' - ' . $name . '.php - was created. (^_^)'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Imanghafoori\Widgets; |
4 | 4 | |
5 | -use Symfony\Component\Console\Input\InputOption; |
|
6 | 5 | use Illuminate\Console\GeneratorCommand as LaravelGeneratorCommand; |
6 | +use Symfony\Component\Console\Input\InputOption; |
|
7 | 7 | |
8 | 8 | class WidgetGenerator extends LaravelGeneratorCommand |
9 | 9 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | private function makeWidgetObj($widget) |
36 | 36 | { |
37 | - $widget = app()->getNamespace().'Widgets\\'.$widget; |
|
37 | + $widget = app()->getNamespace() . 'Widgets\\' . $widget; |
|
38 | 38 | |
39 | 39 | return app($widget); |
40 | 40 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | private function generateJson($widget, ...$args) |
51 | 51 | { |
52 | 52 | // Everything inside this function is executed only when the cache is not available. |
53 | - $expensivePhpCode = function () use ($widget, $args) { |
|
53 | + $expensivePhpCode = function() use ($widget, $args) { |
|
54 | 54 | $data = \App::call($widget->controller, ...$args); |
55 | 55 | |
56 | 56 | // render the template with the resulting data. |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | { |
41 | 41 | $tpl = $this->getTplPath($this->widget->template); |
42 | 42 | |
43 | - $this->html = "<span title='WidgetObj : ".get_class($this->widget).".php
Template : {$tpl}{$this->cacheState()}'>{$this->html}</span>"; |
|
43 | + $this->html = "<span title='WidgetObj : " . get_class($this->widget) . ".php
Template : {$tpl}{$this->cacheState()}'>{$this->html}</span>"; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | private function cacheState() |
52 | 52 | { |
53 | - if (! $this->policies->widgetShouldUseCache()) { |
|
53 | + if (!$this->policies->widgetShouldUseCache()) { |
|
54 | 54 | return ' 
Cache: is globally turned off (You should put "enable_cache" => true in config\widgetize.php) '; |
55 | 55 | } |
56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | private function addHtmlComments() |
61 | 61 | { |
62 | - $this->html = "<!-- '{".get_class($this->widget)."' Widget Start -->".$this->html."<!-- '".get_class($this->widget)."' Widget End -->"; |
|
62 | + $this->html = "<!-- '{" . get_class($this->widget) . "' Widget Start -->" . $this->html . "<!-- '" . get_class($this->widget) . "' Widget End -->"; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | private function getTplPath($tpl) |
70 | 70 | { |
71 | 71 | if (str_contains($tpl, 'Widgets::')) { |
72 | - $tpl = str_replace('Widgets::', app()->getNamespace().'Widgets\\', $tpl); |
|
72 | + $tpl = str_replace('Widgets::', app()->getNamespace() . 'Widgets\\', $tpl); |
|
73 | 73 | } |
74 | 74 | |
75 | - return str_replace('.', '\\', $tpl).'.blade.php'; |
|
75 | + return str_replace('.', '\\', $tpl) . '.blade.php'; |
|
76 | 76 | } |
77 | 77 | } |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | { |
25 | 25 | $this->_registerDebugbar(); |
26 | 26 | $this->publishes([ |
27 | - __DIR__.'/config/config.php' => config_path('widgetize.php'), |
|
27 | + __DIR__ . '/config/config.php' => config_path('widgetize.php'), |
|
28 | 28 | ]); |
29 | 29 | |
30 | 30 | $this->defineDirectives(); |
31 | - $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets'); |
|
31 | + $this->loadViewsFrom($this->app->basePath() . '/app/Widgets/', 'Widgets'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $omitParenthesis = version_compare($this->app->version(), '5.3', '<'); |
40 | 40 | |
41 | - Blade::directive('widget', function ($expression) use ($omitParenthesis) { |
|
41 | + Blade::directive('widget', function($expression) use ($omitParenthesis) { |
|
42 | 42 | $expression = $omitParenthesis ? $expression : "($expression)"; |
43 | 43 | |
44 | 44 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>"; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function register() |
54 | 54 | { |
55 | - $this->mergeConfigFrom(__DIR__.'/config/config.php', 'widgetize'); |
|
55 | + $this->mergeConfigFrom(__DIR__ . '/config/config.php', 'widgetize'); |
|
56 | 56 | $this->commands('command.imanghafoori.widget'); |
57 | 57 | $this->registerSingletons(); |
58 | 58 | $this->registerMacros(); |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | private function registerSingletons() |
65 | 65 | { |
66 | - $this->app->singleton('command.imanghafoori.widget', function ($app) { |
|
66 | + $this->app->singleton('command.imanghafoori.widget', function($app) { |
|
67 | 67 | return $app['Imanghafoori\Widgets\WidgetGenerator']; |
68 | 68 | }); |
69 | 69 | |
70 | - $this->app->singleton(Normalizer::class, function () { |
|
70 | + $this->app->singleton(Normalizer::class, function() { |
|
71 | 71 | $cacheNormalizer = new CacheNormalizer(); |
72 | 72 | $tplNormalizer = new TemplateNormalizer(); |
73 | 73 | $presenterNormalizer = new PresenterNormalizer(); |
@@ -77,55 +77,55 @@ discard block |
||
77 | 77 | return new Utils\Normalizer($tplNormalizer, $cacheNormalizer, $presenterNormalizer, $ctrlNormalizer, $contextAsNormalizer); |
78 | 78 | }); |
79 | 79 | |
80 | - $this->app->singleton(Utils\HtmlMinifier::class, function () { |
|
80 | + $this->app->singleton(Utils\HtmlMinifier::class, function() { |
|
81 | 81 | return new Utils\HtmlMinifier(); |
82 | 82 | }); |
83 | 83 | |
84 | - $this->app->singleton(Utils\DebugInfo::class, function () { |
|
84 | + $this->app->singleton(Utils\DebugInfo::class, function() { |
|
85 | 85 | return new Utils\DebugInfo(); |
86 | 86 | }); |
87 | 87 | |
88 | - $this->app->singleton(Utils\Policies::class, function () { |
|
88 | + $this->app->singleton(Utils\Policies::class, function() { |
|
89 | 89 | return new Utils\Policies(); |
90 | 90 | }); |
91 | 91 | |
92 | - $this->app->singleton(Utils\Cache::class, function () { |
|
92 | + $this->app->singleton(Utils\Cache::class, function() { |
|
93 | 93 | return new Utils\Cache(); |
94 | 94 | }); |
95 | 95 | |
96 | - $this->app->singleton(Utils\CacheTag::class, function () { |
|
96 | + $this->app->singleton(Utils\CacheTag::class, function() { |
|
97 | 97 | return new Utils\CacheTag(); |
98 | 98 | }); |
99 | 99 | |
100 | - $this->app->singleton(Utils\WidgetRenderer::class, function () { |
|
100 | + $this->app->singleton(Utils\WidgetRenderer::class, function() { |
|
101 | 101 | return new Utils\WidgetRenderer(); |
102 | 102 | }); |
103 | 103 | } |
104 | 104 | |
105 | 105 | private function registerMacros() |
106 | 106 | { |
107 | - Route::macro('view', function ($url, $view, $name = null) { |
|
107 | + Route::macro('view', function($url, $view, $name = null) { |
|
108 | 108 | return Route::get($url, [ |
109 | 109 | 'as' => $name, |
110 | - 'uses' => function () use ($view) { |
|
110 | + 'uses' => function() use ($view) { |
|
111 | 111 | return view($view); |
112 | 112 | }, |
113 | 113 | ]); |
114 | 114 | }); |
115 | 115 | |
116 | - Route::macro('widget', function ($url, $widget, $name = null) { |
|
116 | + Route::macro('widget', function($url, $widget, $name = null) { |
|
117 | 117 | return Route::get($url, [ |
118 | 118 | 'as' => $name, |
119 | - 'uses' => function (...$args) use ($widget) { |
|
119 | + 'uses' => function(...$args) use ($widget) { |
|
120 | 120 | return render_widget($widget, $args); |
121 | 121 | }, |
122 | 122 | ]); |
123 | 123 | }); |
124 | 124 | |
125 | - Route::macro('jsonWidget', function ($url, $widget, $name = null) { |
|
125 | + Route::macro('jsonWidget', function($url, $widget, $name = null) { |
|
126 | 126 | return Route::get($url, [ |
127 | 127 | 'as' => $name, |
128 | - 'uses' => function (...$args) use ($widget) { |
|
128 | + 'uses' => function(...$args) use ($widget) { |
|
129 | 129 | return json_widget($widget, $args); |
130 | 130 | }, |
131 | 131 | ]); |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | |
135 | 135 | private function _registerDebugbar() |
136 | 136 | { |
137 | - if (! $this->app->offsetExists('debugbar')) { |
|
137 | + if (!$this->app->offsetExists('debugbar')) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | - $this->app->singleton('widgetize.debugger', function () { |
|
140 | + $this->app->singleton('widgetize.debugger', function() { |
|
141 | 141 | return new MessagesCollector('Widgets'); |
142 | 142 | }); |
143 | 143 |