@@ -40,7 +40,7 @@ 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 | if (strpos($expression, 'slotable') == false) { |
| 46 | 46 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>"; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $this->defineSlotDirectives($omitParenthesis); |
| 52 | 52 | |
| 53 | - Blade::directive('endwidget', function () { |
|
| 53 | + Blade::directive('endwidget', function() { |
|
| 54 | 54 | $expression = $this->expression; |
| 55 | 55 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>"; |
| 56 | 56 | }); |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | private function defineSlotDirectives($omitParenthesis) |
| 70 | 70 | { |
| 71 | - Blade::directive('slot', function ($slotName) use ($omitParenthesis) { |
|
| 71 | + Blade::directive('slot', function($slotName) use ($omitParenthesis) { |
|
| 72 | 72 | $slotName = $omitParenthesis ? $slotName : "($slotName)"; |
| 73 | 73 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->startSlot{$slotName};?>"; |
| 74 | 74 | }); |
| 75 | 75 | |
| 76 | - Blade::directive('endslot', function () { |
|
| 76 | + Blade::directive('endslot', function() { |
|
| 77 | 77 | $contentKey = '$content'; |
| 78 | 78 | return "<?php |
| 79 | 79 | $contentKey = ob_get_clean(); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $this->app->singleton('widgetize.debugger', function () { |
|
| 104 | + $this->app->singleton('widgetize.debugger', function() { |
|
| 105 | 105 | return new MessagesCollector('Widgets'); |
| 106 | 106 | }); |
| 107 | 107 | |
@@ -30,7 +30,8 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | private function assignSlots() |
| 32 | 32 | { |
| 33 | - if ($this->hasSlot()) |
|
| 34 | - $this->_viewData = array_merge($this->_viewData, $this->slots); |
|
| 33 | + if ($this->hasSlot()) { |
|
| 34 | + $this->_viewData = array_merge($this->_viewData, $this->slots); |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | } |
@@ -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]); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | return resolve($widget); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $widget = app()->getNamespace().'Widgets\\'.$widget; |
|
| 61 | + $widget = app()->getNamespace() . 'Widgets\\' . $widget; |
|
| 62 | 62 | |
| 63 | 63 | return resolve($widget); |
| 64 | 64 | } |
@@ -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 | $this->assignSlots(); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | return $this->renderTemplate($widget, ...$args); |
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | - if (! $widget->cacheView) { |
|
| 85 | + if (!$widget->cacheView) { |
|
| 86 | 86 | return $expensivePhpCode(); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | private function makeDataForView($widget, array $args) |
| 100 | 100 | { |
| 101 | - $expensiveCode = function () use ($widget, $args) { |
|
| 101 | + $expensiveCode = function() use ($widget, $args) { |
|
| 102 | 102 | $viewData = $this->callController($widget, $args); |
| 103 | 103 | |
| 104 | 104 | if ($widget->presenter) { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | try { |
| 132 | 132 | $this->html = view($widget->template, $data)->render(); |
| 133 | 133 | } catch (\Throwable $t) { |
| 134 | - throw new \ErrorException('There was some error rendering '.get_class($widget).', template file: \''.$widget->template.'\' Error: '.$t->getMessage()); |
|
| 134 | + throw new \ErrorException('There was some error rendering ' . get_class($widget) . ', template file: \'' . $widget->template . '\' Error: ' . $t->getMessage()); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // We try to minify the html before storing it in cache to save space. |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | private function callController($widget, array $args) |
| 152 | 152 | { |
| 153 | - if (! isset($widget->controller)) { |
|
| 153 | + if (!isset($widget->controller)) { |
|
| 154 | 154 | $viewData = []; |
| 155 | 155 | } elseif (is_array($widget->controller) && is_string($widget->controller[0])) { |
| 156 | 156 | $viewData = call_user_func_array($widget->controller, $args); |