@@ -255,6 +255,10 @@ |
||
255 | 255 | return ((env('WIDGET_CACHE', false) !== false) and (!app()->environment('testing')) and ($this->cacheLifeTime !== 0)); |
256 | 256 | } |
257 | 257 | |
258 | + /** |
|
259 | + * @param string $key |
|
260 | + * @param \Closure $phpCode |
|
261 | + */ |
|
258 | 262 | private function cacheResult($key, $phpCode) |
259 | 263 | { |
260 | 264 | $cache = app()->make('cache'); |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | $presenter = get_called_class() . 'Presenter'; |
61 | 61 | |
62 | 62 | if (class_exists($presenter)) { |
63 | - $this->presenter = $presenter.'@presenter'; |
|
64 | - }else{ |
|
63 | + $this->presenter = $presenter . '@presenter'; |
|
64 | + } else { |
|
65 | 65 | $this->presenter = null; |
66 | 66 | } |
67 | 67 | } else { |
68 | 68 | if (class_exists($this->presenter) === false) { |
69 | 69 | throw new \InvalidArgumentException("Presenter Class [{$this->presenter}] not found."); |
70 | 70 | } |
71 | - $this->presenter = $this->presenter.'@present'; |
|
71 | + $this->presenter = $this->presenter . '@present'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | private function generateHtml(...$args) |
143 | 143 | { |
144 | 144 | // Everything inside this function is executed only when the cache is not available. |
145 | - $expensivePhpCode = function () use ($args) { |
|
145 | + $expensivePhpCode = function() use ($args) { |
|
146 | 146 | $this->prepareDataForView($args); |
147 | 147 | |
148 | 148 | // render the template with the resulting data. |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | // We add some HTML comments before and after the widget output |
191 | 191 | // So then, we will be able to easily identify the widget in browser's developer tool. |
192 | - if (env('WIDGET_IDENTIFIER', true) and env('APP_ENV','production') === 'local') { |
|
192 | + if (env('WIDGET_IDENTIFIER', true) and env('APP_ENV', 'production') === 'local') { |
|
193 | 193 | $this->addIdentifierToHtml(); |
194 | 194 | } |
195 | 195 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | private function addIdentifierToHtml() |
227 | 227 | { |
228 | 228 | $name = $this->friendlyName; |
229 | - $this->html = "<div title='". get_called_class() . "::class || template : {$this->template}".$this->cacheState()."style='box-shadow: 0px 0px 15px 5px #00c62b inset'>" . $this->html ."</div>"; |
|
229 | + $this->html = "<div title='" . get_called_class() . "::class || template : {$this->template}" . $this->cacheState() . "style='box-shadow: 0px 0px 15px 5px #00c62b inset'>" . $this->html . "</div>"; |
|
230 | 230 | $this->html = "<!-- '$name' Widget Start -->" . $this->html . "<!-- '$name' Widget End -->"; |
231 | 231 | } |
232 | 232 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $cache = app()->make('cache'); |
261 | 261 | |
262 | - if($this->cacheTags){ |
|
262 | + if ($this->cacheTags) { |
|
263 | 263 | $cache = $cache->tags($this->cacheTags); |
264 | 264 | } |
265 | 265 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function cacheShouldBeTagged() |
288 | 288 | { |
289 | - return !in_array(env('CACHE_DRIVER','file'), ['file', 'database']) and $this->cacheTags; |
|
289 | + return !in_array(env('CACHE_DRIVER', 'file'), ['file', 'database']) and $this->cacheTags; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | private function cacheState() |
296 | 296 | { |
297 | - if($this->widgetShouldUseCache()){ |
|
297 | + if ($this->widgetShouldUseCache()) { |
|
298 | 298 | return " || cache: {$this->cacheLifeTime}(min)' "; |
299 | 299 | } |
300 | 300 | return " || cache : off"; |
@@ -61,7 +61,7 @@ |
||
61 | 61 | |
62 | 62 | if (class_exists($presenter)) { |
63 | 63 | $this->presenter = $presenter.'@presenter'; |
64 | - }else{ |
|
64 | + } else{ |
|
65 | 65 | $this->presenter = null; |
66 | 66 | } |
67 | 67 | } else { |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | class WidgetGenerator extends LaravelGeneratorCommand |
8 | 8 | { |
9 | - /** |
|
9 | + /** |
|
10 | 10 | * The name and signature of the console command. |
11 | 11 | * |
12 | 12 | * @var string |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | protected function getStub() |
36 | 36 | { |
37 | 37 | |
38 | - return __DIR__.'/../stubs/widget.stub'; |
|
38 | + return __DIR__.'/../stubs/widget.stub'; |
|
39 | 39 | |
40 | 40 | } |
41 | 41 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | protected function getStub() |
36 | 36 | { |
37 | 37 | |
38 | - return __DIR__.'/../stubs/widget.stub'; |
|
38 | + return __DIR__ . '/../stubs/widget.stub'; |
|
39 | 39 | |
40 | 40 | } |
41 | 41 |
@@ -7,32 +7,32 @@ |
||
7 | 7 | |
8 | 8 | class WidgetsServiceProvider extends ServiceProvider { |
9 | 9 | |
10 | - /** |
|
11 | - * Bootstrap any application services. |
|
12 | - * |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function boot() |
|
16 | - { |
|
10 | + /** |
|
11 | + * Bootstrap any application services. |
|
12 | + * |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function boot() |
|
16 | + { |
|
17 | 17 | $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets'); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * Register any application services. |
|
22 | - * |
|
23 | - * This service provider is a great spot to register your various container |
|
24 | - * bindings with the application. As you can see, we are registering our |
|
25 | - * "Registrar" implementation here. You can add your own bindings too! |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function register() |
|
30 | - { |
|
31 | - $this->app->singleton('command.imanghafoori.widget', function ($app) { |
|
20 | + /** |
|
21 | + * Register any application services. |
|
22 | + * |
|
23 | + * This service provider is a great spot to register your various container |
|
24 | + * bindings with the application. As you can see, we are registering our |
|
25 | + * "Registrar" implementation here. You can add your own bindings too! |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function register() |
|
30 | + { |
|
31 | + $this->app->singleton('command.imanghafoori.widget', function ($app) { |
|
32 | 32 | return $app['Imanghafoori\Widgets\WidgetGenerator']; |
33 | 33 | }); |
34 | 34 | |
35 | 35 | $this->commands('command.imanghafoori.widget'); |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function boot() |
16 | 16 | { |
17 | - $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets'); |
|
17 | + $this->loadViewsFrom($this->app->basePath() . '/app/Widgets/', 'Widgets'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function register() |
30 | 30 | { |
31 | - $this->app->singleton('command.imanghafoori.widget', function ($app) { |
|
31 | + $this->app->singleton('command.imanghafoori.widget', function($app) { |
|
32 | 32 | return $app['Imanghafoori\Widgets\WidgetGenerator']; |
33 | 33 | }); |
34 | 34 |