@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function cacheResult(array $args, callable $phpCode, $widgetObj, $form = 'HTML') |
31 | 31 | { |
32 | - if (! resolve(Policies::class)->widgetShouldUseCache() || $widgetObj->cacheLifeTime->s === 0) { |
|
32 | + if (!resolve(Policies::class)->widgetShouldUseCache() || $widgetObj->cacheLifeTime->s === 0) { |
|
33 | 33 | return $phpCode(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $cache = resolve('cache'); |
37 | 37 | |
38 | - if (! empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) { |
|
38 | + if (!empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) { |
|
39 | 39 | $cache = $cache->tags($widgetObj->cacheTags); |
40 | 40 | } |
41 | 41 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | $_key = json_encode($widget->extraCacheKeyDependency($arg)); |
65 | 65 | } |
66 | 66 | |
67 | - if (! $this->cacheDriverSupportsTags()) { |
|
67 | + if (!$this->cacheDriverSupportsTags()) { |
|
68 | 68 | $_key .= json_encode($this->getTagTokens($widget->cacheTags)); |
69 | 69 | } |
70 | 70 | |
71 | - $_key .= json_encode($arg, JSON_FORCE_OBJECT).app()->getLocale().$form.$widget->template.get_class($widget); |
|
71 | + $_key .= json_encode($arg, JSON_FORCE_OBJECT) . app()->getLocale() . $form . $widget->template . get_class($widget); |
|
72 | 72 | |
73 | 73 | return md5($_key); |
74 | 74 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function cacheDriverSupportsTags(): bool |
81 | 81 | { |
82 | - return ! in_array(config('cache.default', 'file'), ['file', 'database']); |
|
82 | + return !in_array(config('cache.default', 'file'), ['file', 'database']); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | private function getTagTokens(array $cacheTags) |
90 | 90 | { |
91 | - return array_map(function ($tag) { |
|
91 | + return array_map(function($tag) { |
|
92 | 92 | return $this->_cacheTag->getTagToken($tag); |
93 | 93 | }, $cacheTags); |
94 | 94 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return \Cache::tags($tags)->flush(); |
104 | 104 | } |
105 | 105 | |
106 | - foreach ((array) $tags as $tag) { |
|
106 | + foreach ((array)$tags as $tag) { |
|
107 | 107 | $this->_cacheTag->generateNewToken($tag); |
108 | 108 | } |
109 | 109 | } |
@@ -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 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | */ |
27 | 27 | private function checkPresentMethodExists($presenter): void |
28 | 28 | { |
29 | - if (! method_exists($presenter, 'present')) { |
|
30 | - throw new \InvalidArgumentException("'present' method not found on : ".$presenter); |
|
29 | + if (!method_exists($presenter, 'present')) { |
|
30 | + throw new \InvalidArgumentException("'present' method not found on : " . $presenter); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | private function checkPresenterExists($presenter): void |
38 | 38 | { |
39 | - if (! class_exists($presenter)) { |
|
39 | + if (!class_exists($presenter)) { |
|
40 | 40 | throw new \InvalidArgumentException("Presenter Class [{$presenter}] not found."); |
41 | 41 | } |
42 | 42 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | $presenter = $widget->presenter; |
52 | 52 | $this->checkPresenterExists($presenter); |
53 | 53 | } else { |
54 | - $presenter = get_class($widget).'Presenter'; |
|
55 | - if (! class_exists($presenter)) { |
|
54 | + $presenter = get_class($widget) . 'Presenter'; |
|
55 | + if (!class_exists($presenter)) { |
|
56 | 56 | $widget->presenter = null; |
57 | 57 | } |
58 | 58 | } |
@@ -15,17 +15,17 @@ |
||
15 | 15 | public function normalize($widget): void |
16 | 16 | { |
17 | 17 | // class name without namespace. |
18 | - $className = str_replace(app()->getNamespace().'Widgets\\', '', get_class($widget)); |
|
18 | + $className = str_replace(app()->getNamespace() . 'Widgets\\', '', get_class($widget)); |
|
19 | 19 | |
20 | 20 | // replace slashes with dots |
21 | 21 | $className = str_replace(['\\', '/'], '.', $className); |
22 | 22 | |
23 | - if (! property_exists($widget, 'template')) { |
|
24 | - $widget->template = 'Widgets::'.$className.'View'; |
|
23 | + if (!property_exists($widget, 'template')) { |
|
24 | + $widget->template = 'Widgets::' . $className . 'View'; |
|
25 | 25 | } |
26 | 26 | |
27 | - if (! view()->exists($widget->template)) { |
|
28 | - throw new \InvalidArgumentException("View file \"{$widget->template}\" not found by: '".get_class($widget)." '"); |
|
27 | + if (!view()->exists($widget->template)) { |
|
28 | + throw new \InvalidArgumentException("View file \"{$widget->template}\" not found by: '" . get_class($widget) . " '"); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | } |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | { |
20 | 20 | $this->_registerDebugbar(); |
21 | 21 | $this->publishes([ |
22 | - __DIR__.'/config/config.php' => config_path('widgetize.php'), |
|
22 | + __DIR__ . '/config/config.php' => config_path('widgetize.php'), |
|
23 | 23 | ]); |
24 | 24 | |
25 | 25 | $this->defineDirectives(); |
26 | - $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets'); |
|
26 | + $this->loadViewsFrom($this->app->basePath() . '/app/Widgets/', 'Widgets'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | { |
41 | 41 | $omitParenthesis = version_compare($this->app->version(), '5.3', '<'); |
42 | 42 | |
43 | - Blade::directive('widget', function ($expression) use ($omitParenthesis) { |
|
43 | + Blade::directive('widget', function($expression) use ($omitParenthesis) { |
|
44 | 44 | $expression = $omitParenthesis ? $expression : "($expression)"; |
45 | 45 | |
46 | 46 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>"; |
47 | 47 | }); |
48 | 48 | |
49 | - Blade::directive('slotWidget', function ($expression) use ($omitParenthesis) { |
|
49 | + Blade::directive('slotWidget', function($expression) use ($omitParenthesis) { |
|
50 | 50 | $this->expression = $omitParenthesis ? $expression : "($expression)"; |
51 | 51 | }); |
52 | 52 | |
53 | 53 | $this->defineSlotDirectives($omitParenthesis); |
54 | 54 | |
55 | - Blade::directive('endSlotWidget', function () { |
|
55 | + Blade::directive('endSlotWidget', function() { |
|
56 | 56 | $expression = $this->expression; |
57 | 57 | |
58 | 58 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>"; |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | */ |
72 | 72 | private function defineSlotDirectives($omitParenthesis) |
73 | 73 | { |
74 | - Blade::directive('slot', function ($slotName) use ($omitParenthesis) { |
|
74 | + Blade::directive('slot', function($slotName) use ($omitParenthesis) { |
|
75 | 75 | $slotName = $omitParenthesis ? $slotName : "($slotName)"; |
76 | 76 | |
77 | 77 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->startSlot{$slotName};?>"; |
78 | 78 | }); |
79 | 79 | |
80 | - Blade::directive('endSlot', function () { |
|
80 | + Blade::directive('endSlot', function() { |
|
81 | 81 | $contentKey = '$content'; |
82 | 82 | |
83 | 83 | return "<?php |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function register() |
96 | 96 | { |
97 | - $this->mergeConfigFrom(__DIR__.'/config/config.php', 'widgetize'); |
|
97 | + $this->mergeConfigFrom(__DIR__ . '/config/config.php', 'widgetize'); |
|
98 | 98 | $this->commands('command.imanghafoori.widget'); |
99 | 99 | app(RouteMacros::class)->registerMacros(); |
100 | 100 | app(SingletonServices::class)->registerSingletons($this->app); |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | |
103 | 103 | private function _registerDebugbar() |
104 | 104 | { |
105 | - if (! $this->app->offsetExists('debugbar')) { |
|
105 | + if (!$this->app->offsetExists('debugbar')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | - $this->app->singleton('widgetize.debugger', function () { |
|
109 | + $this->app->singleton('widgetize.debugger', function() { |
|
110 | 110 | return new MessagesCollector('Widgets'); |
111 | 111 | }); |
112 | 112 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function hasSlots() |
39 | 39 | { |
40 | - return ! empty($this->slots); |
|
40 | + return !empty($this->slots); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | if (is_array($widget)) { |
37 | - $widget = (object) $widget; |
|
37 | + $widget = (object)$widget; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | event('widgetize.rendering_widget', [$widget]); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | private function generateHtml($widget, ...$args) |
75 | 75 | { |
76 | 76 | // Everything inside this function is executed only when the cache is not available. |
77 | - $expensivePhpCode = function () use ($widget, $args) { |
|
77 | + $expensivePhpCode = function() use ($widget, $args) { |
|
78 | 78 | $this->makeDataForView($widget, $args); |
79 | 79 | |
80 | 80 | return $this->renderTemplate($widget, ...$args); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | private function makeDataForView($widget, array $args) |
98 | 98 | { |
99 | - $expensiveCode = function () use ($widget, $args) { |
|
99 | + $expensiveCode = function() use ($widget, $args) { |
|
100 | 100 | $viewData = $this->callController($widget, $args); |
101 | 101 | |
102 | 102 | if ($widget->presenter) { |