@@ -1,20 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('render_widget')) { |
|
3 | +if (!function_exists('render_widget')) { |
|
4 | 4 | function render_widget($widget, ...$args) |
5 | 5 | { |
6 | 6 | return app(\Imanghafoori\Widgets\Utils\WidgetRenderer::class)->renderWidget($widget, ...$args); |
7 | 7 | } |
8 | 8 | } |
9 | 9 | |
10 | -if (! function_exists('expire_widgets')) { |
|
10 | +if (!function_exists('expire_widgets')) { |
|
11 | 11 | function expire_widgets($tags) |
12 | 12 | { |
13 | 13 | return app(\Imanghafoori\Widgets\Utils\Cache::class)->expireTaggedWidgets($tags); |
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | -if (! function_exists('json_widget')) { |
|
17 | +if (!function_exists('json_widget')) { |
|
18 | 18 | function json_widget($widget, ...$args) |
19 | 19 | { |
20 | 20 | return app(\Imanghafoori\Widgets\Utils\WidgetJsonifier::class)->jsonResponse($widget, ...$args); |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $contextAs = 'data'; |
61 | 61 | if (property_exists($widget, 'contextAs')) { |
62 | 62 | // removes the $ sign. |
63 | - $contextAs = str_replace('$', '', (string) $widget->contextAs); |
|
63 | + $contextAs = str_replace('$', '', (string)$widget->contextAs); |
|
64 | 64 | } |
65 | 65 | $widget->contextAs = $contextAs; |
66 | 66 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return app($widget); |
53 | 53 | } |
54 | 54 | |
55 | - $widget = app()->getNamespace().'Widgets\\'.$widget; |
|
55 | + $widget = app()->getNamespace() . 'Widgets\\' . $widget; |
|
56 | 56 | |
57 | 57 | return app($widget); |
58 | 58 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | private function generateHtml($widget, ...$args) |
69 | 69 | { |
70 | 70 | // Everything inside this function is executed only when the cache is not available. |
71 | - $expensivePhpCode = function () use ($widget, $args) { |
|
71 | + $expensivePhpCode = function() use ($widget, $args) { |
|
72 | 72 | $this->makeDataForView($widget, $args); |
73 | 73 | |
74 | 74 | // render the template with the resulting data. |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | { |
18 | 18 | $this->_registerDebugbar(); |
19 | 19 | $this->publishes([ |
20 | - __DIR__.'/config/config.php' => config_path('widgetize.php'), |
|
20 | + __DIR__ . '/config/config.php' => config_path('widgetize.php'), |
|
21 | 21 | ]); |
22 | 22 | |
23 | 23 | $this->defineDirectives(); |
24 | - $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets'); |
|
24 | + $this->loadViewsFrom($this->app->basePath() . '/app/Widgets/', 'Widgets'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -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 | app(RouteMacros::class)->registerMacros(); |
58 | 58 | app(SingletonServices::class)->registerSingletons($this->app); |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | |
61 | 61 | private function _registerDebugbar() |
62 | 62 | { |
63 | - if (! $this->app->offsetExists('debugbar')) { |
|
63 | + if (!$this->app->offsetExists('debugbar')) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | - $this->app->singleton('widgetize.debugger', function () { |
|
67 | + $this->app->singleton('widgetize.debugger', function() { |
|
68 | 68 | return new MessagesCollector('Widgets'); |
69 | 69 | }); |
70 | 70 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | private function persistToken(string $tag, string $token): void |
65 | 65 | { |
66 | - \Cache::forever('9z10_o6cg_r'.$tag, $token); |
|
66 | + \Cache::forever('9z10_o6cg_r' . $tag, $token); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -72,6 +72,6 @@ discard block |
||
72 | 72 | */ |
73 | 73 | private function getPersistedToken(string $tag): ?string |
74 | 74 | { |
75 | - return \Cache::get('9z10_o6cg_r'.$tag, null); |
|
75 | + return \Cache::get('9z10_o6cg_r' . $tag, null); |
|
76 | 76 | } |
77 | 77 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | private function makeWidgetObj(string $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. |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $cache = app('cache'); |
32 | 32 | |
33 | - if (! empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) { |
|
33 | + if (!empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) { |
|
34 | 34 | $cache = $cache->tags($widgetObj->cacheTags); |
35 | 35 | } |
36 | 36 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | $_key = json_encode($widget->extraCacheKeyDependency($arg)); |
62 | 62 | } |
63 | 63 | |
64 | - if (! $this->cacheDriverSupportsTags()) { |
|
64 | + if (!$this->cacheDriverSupportsTags()) { |
|
65 | 65 | $_key .= json_encode($this->getTagTokens($widget->cacheTags)); |
66 | 66 | } |
67 | 67 | |
68 | - $_key .= json_encode($arg, JSON_FORCE_OBJECT).app()->getLocale().$form.$widget->template.get_class($widget); |
|
68 | + $_key .= json_encode($arg, JSON_FORCE_OBJECT) . app()->getLocale() . $form . $widget->template . get_class($widget); |
|
69 | 69 | |
70 | 70 | return md5($_key); |
71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function cacheDriverSupportsTags() : bool |
78 | 78 | { |
79 | - return ! in_array(config('cache.default', 'file'), ['file', 'database']); |
|
79 | + return !in_array(config('cache.default', 'file'), ['file', 'database']); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | private function getTagTokens(array $cacheTags) |
87 | 87 | { |
88 | - return array_map(function ($tag) { |
|
88 | + return array_map(function($tag) { |
|
89 | 89 | return $this->_cacheTag->getTagToken($tag); |
90 | 90 | }, $cacheTags); |
91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return \Cache::tags($tags)->flush(); |
101 | 101 | } |
102 | 102 | |
103 | - foreach ((array) $tags as $tag) { |
|
103 | + foreach ((array)$tags as $tag) { |
|
104 | 104 | $this->_cacheTag->generateNewToken($tag); |
105 | 105 | } |
106 | 106 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | private function checkControllerExists(string $ctrlClass): void |
28 | 28 | { |
29 | - if (! class_exists($ctrlClass)) { |
|
29 | + if (!class_exists($ctrlClass)) { |
|
30 | 30 | throw new \InvalidArgumentException("Controller class: [{$ctrlClass}] not found."); |
31 | 31 | } |
32 | 32 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | private function checkDataMethodExists(string $ctrlClass): void |
38 | 38 | { |
39 | - if (! method_exists($ctrlClass, 'data')) { |
|
40 | - throw new \InvalidArgumentException("'data' method not found on ".$ctrlClass); |
|
39 | + if (!method_exists($ctrlClass, 'data')) { |
|
40 | + throw new \InvalidArgumentException("'data' method not found on " . $ctrlClass); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | // then we decide to call data method on that instead. |
56 | 56 | if (property_exists($widget, 'controller')) { |
57 | 57 | $ctrlClass = $widget->controller; |
58 | - $controllerMethod = ($ctrlClass).'@data'; |
|
58 | + $controllerMethod = ($ctrlClass) . '@data'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return [$controllerMethod, $ctrlClass]; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | if ($widget->presenter) { |
19 | 19 | $this->checkPresentMethodExists($presenter); |
20 | - $widget->presenter = $presenter.'@present'; |
|
20 | + $widget->presenter = $presenter . '@present'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | } |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | */ |
28 | 28 | private function checkPresentMethodExists($presenter) : void |
29 | 29 | { |
30 | - if (! method_exists($presenter, 'present')) { |
|
31 | - throw new \InvalidArgumentException("'present' method not found on : ".$presenter); |
|
30 | + if (!method_exists($presenter, 'present')) { |
|
31 | + throw new \InvalidArgumentException("'present' method not found on : " . $presenter); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private function checkPresenterExists($presenter): void |
39 | 39 | { |
40 | - if (! class_exists($presenter)) { |
|
40 | + if (!class_exists($presenter)) { |
|
41 | 41 | throw new \InvalidArgumentException("Presenter Class [{$presenter}] not found."); |
42 | 42 | } |
43 | 43 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | $presenter = $widget->presenter; |
53 | 53 | $this->checkPresenterExists($presenter); |
54 | 54 | } else { |
55 | - $presenter = get_class($widget).'Presenter'; |
|
56 | - if (! class_exists($presenter)) { |
|
55 | + $presenter = get_class($widget) . 'Presenter'; |
|
56 | + if (!class_exists($presenter)) { |
|
57 | 57 | $widget->presenter = null; |
58 | 58 | } |
59 | 59 | } |