@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | $presenter = $widget->presenter; |
16 | 16 | $this->checkPresenterExists($presenter); |
17 | 17 | } else { |
18 | - $presenter = get_class($widget).'Presenter'; |
|
19 | - if (! class_exists($presenter)) { |
|
18 | + $presenter = get_class($widget) . 'Presenter'; |
|
19 | + if (!class_exists($presenter)) { |
|
20 | 20 | return $widget->presenter = null; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | 24 | $this->checkPresentMethodExists($presenter); |
25 | 25 | |
26 | - $widget->presenter = $presenter.'@present'; |
|
26 | + $widget->presenter = $presenter . '@present'; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | private function checkPresentMethodExists($presenter) |
33 | 33 | { |
34 | - if (! method_exists($presenter, 'present')) { |
|
35 | - throw new \InvalidArgumentException("'present' method not found on : ".$presenter); |
|
34 | + if (!method_exists($presenter, 'present')) { |
|
35 | + throw new \InvalidArgumentException("'present' method not found on : " . $presenter); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | private function checkPresenterExists($presenter) |
43 | 43 | { |
44 | - if (! class_exists($presenter)) { |
|
44 | + if (!class_exists($presenter)) { |
|
45 | 45 | throw new \InvalidArgumentException("Presenter Class [{$presenter}] not found."); |
46 | 46 | } |
47 | 47 | } |
@@ -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 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function widgetShouldUseCache() |
25 | 25 | { |
26 | - return config('widgetize.enable_cache') && (! app()->environment('testing')); |
|
26 | + return config('widgetize.enable_cache') && (!app()->environment('testing')); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -17,12 +17,12 @@ |
||
17 | 17 | // replace slashes with dots |
18 | 18 | $className = str_replace(['\\', '/'], '.', $className); |
19 | 19 | |
20 | - if (! property_exists($widget, 'template')) { |
|
21 | - $widget->template = 'Widgets::'.$className.'View'; |
|
20 | + if (!property_exists($widget, 'template')) { |
|
21 | + $widget->template = 'Widgets::' . $className . 'View'; |
|
22 | 22 | } |
23 | 23 | |
24 | - if (! view()->exists($widget->template)) { |
|
25 | - throw new \InvalidArgumentException("View file \"{$widget->template}\" not found by: '".get_class($widget)." '"); |
|
24 | + if (!view()->exists($widget->template)) { |
|
25 | + throw new \InvalidArgumentException("View file \"{$widget->template}\" not found by: '" . get_class($widget) . " '"); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | { |
31 | 31 | $tpl = $this->widget->template; |
32 | 32 | if (str_contains($tpl, 'Widgets::')) { |
33 | - $tpl = str_replace('Widgets::', app()->getNamespace().'Widgets\\', $tpl); |
|
33 | + $tpl = str_replace('Widgets::', app()->getNamespace() . 'Widgets\\', $tpl); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $tpl = str_replace('.', '\\', $tpl); |
37 | 37 | |
38 | - $this->html = "<span title='WidgetObj : ".get_class($this->widget).".php
Template : {$tpl}.blade.php{$this->cacheState()}'>{$this->html}</span>"; |
|
38 | + $this->html = "<span title='WidgetObj : " . get_class($this->widget) . ".php
Template : {$tpl}.blade.php{$this->cacheState()}'>{$this->html}</span>"; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | private function cacheState() |
46 | 46 | { |
47 | - if (! $this->policies->widgetShouldUseCache()) { |
|
47 | + if (!$this->policies->widgetShouldUseCache()) { |
|
48 | 48 | return ' 
Cache: is globally turned off (You should put "enable_cache" => true in config\widgetize.php) '; |
49 | 49 | } |
50 | 50 | |
@@ -53,6 +53,6 @@ discard block |
||
53 | 53 | |
54 | 54 | private function addHtmlComments() |
55 | 55 | { |
56 | - $this->html = "<!-- '{".get_class($this->widget)."' Widget Start -->".$this->html."<!-- '".get_class($this->widget)."' Widget End -->"; |
|
56 | + $this->html = "<!-- '{" . get_class($this->widget) . "' Widget Start -->" . $this->html . "<!-- '" . get_class($this->widget) . "' Widget End -->"; |
|
57 | 57 | } |
58 | 58 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | private function persistToken($tag, $token) |
53 | 53 | { |
54 | - \Cache::forever('9z10_o6cg_r'.$tag, $token); |
|
54 | + \Cache::forever('9z10_o6cg_r' . $tag, $token); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,6 +60,6 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function getPersistedToken($tag) |
62 | 62 | { |
63 | - return \Cache::get('9z10_o6cg_r'.$tag, null); |
|
63 | + return \Cache::get('9z10_o6cg_r' . $tag, null); |
|
64 | 64 | } |
65 | 65 | } |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function normalizeCacheLifeTime($widget) |
13 | 13 | { |
14 | - if (! property_exists($widget, 'cacheLifeTime')) { |
|
15 | - $widget->cacheLifeTime = (int) (config('widgetize.default_cache_lifetime', 0)); |
|
14 | + if (!property_exists($widget, 'cacheLifeTime')) { |
|
15 | + $widget->cacheLifeTime = (int)(config('widgetize.default_cache_lifetime', 0)); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if ($widget->cacheLifeTime === 'forever' || $widget->cacheLifeTime < 0) { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function normalizeCacheTags($widget) |
30 | 30 | { |
31 | - if (! property_exists($widget, 'cacheTags')) { |
|
31 | + if (!property_exists($widget, 'cacheTags')) { |
|
32 | 32 | return $widget->cacheTags = []; |
33 | 33 | } |
34 | 34 |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | public function boot() |
22 | 22 | { |
23 | 23 | $this->publishes([ |
24 | - __DIR__.'/config/config.php' => config_path('widgetize.php'), |
|
24 | + __DIR__ . '/config/config.php' => config_path('widgetize.php'), |
|
25 | 25 | ]); |
26 | 26 | |
27 | 27 | $this->_defineDirectives(); |
28 | - $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets'); |
|
28 | + $this->loadViewsFrom($this->app->basePath() . '/app/Widgets/', 'Widgets'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $omitParenthesis = version_compare($this->app->version(), '5.3', '<'); |
37 | 37 | |
38 | - Blade::directive('widget', function ($expression) use ($omitParenthesis) { |
|
38 | + Blade::directive('widget', function($expression) use ($omitParenthesis) { |
|
39 | 39 | $expression = $omitParenthesis ? $expression : "($expression)"; |
40 | 40 | |
41 | 41 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>"; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function register() |
51 | 51 | { |
52 | - $this->mergeConfigFrom(__DIR__.'/config/config.php', 'widgetize'); |
|
52 | + $this->mergeConfigFrom(__DIR__ . '/config/config.php', 'widgetize'); |
|
53 | 53 | $this->commands('command.imanghafoori.widget'); |
54 | 54 | $this->_registerSingletons(); |
55 | 55 | $this->_registerMacros(); |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function _registerSingletons() |
62 | 62 | { |
63 | - $this->app->singleton('command.imanghafoori.widget', function ($app) { |
|
63 | + $this->app->singleton('command.imanghafoori.widget', function($app) { |
|
64 | 64 | return $app['Imanghafoori\Widgets\WidgetGenerator']; |
65 | 65 | }); |
66 | 66 | |
67 | - $this->app->singleton(Normalizer::class, function () { |
|
67 | + $this->app->singleton(Normalizer::class, function() { |
|
68 | 68 | $cacheNormalizer = new CacheNormalizer(); |
69 | 69 | $tplNormalizer = new TemplateNormalizer(); |
70 | 70 | $presenterNormalizer = new PresenterNormalizer(); |
@@ -73,55 +73,55 @@ discard block |
||
73 | 73 | return new Utils\Normalizer($tplNormalizer, $cacheNormalizer, $presenterNormalizer, $ctrlNormalizer); |
74 | 74 | }); |
75 | 75 | |
76 | - $this->app->singleton(Utils\HtmlMinifier::class, function () { |
|
76 | + $this->app->singleton(Utils\HtmlMinifier::class, function() { |
|
77 | 77 | return new Utils\HtmlMinifier(); |
78 | 78 | }); |
79 | 79 | |
80 | - $this->app->singleton(Utils\DebugInfo::class, function () { |
|
80 | + $this->app->singleton(Utils\DebugInfo::class, function() { |
|
81 | 81 | return new Utils\DebugInfo(); |
82 | 82 | }); |
83 | 83 | |
84 | - $this->app->singleton(Utils\Policies::class, function () { |
|
84 | + $this->app->singleton(Utils\Policies::class, function() { |
|
85 | 85 | return new Utils\Policies(); |
86 | 86 | }); |
87 | 87 | |
88 | - $this->app->singleton(Utils\Cache::class, function () { |
|
88 | + $this->app->singleton(Utils\Cache::class, function() { |
|
89 | 89 | return new Utils\Cache(); |
90 | 90 | }); |
91 | 91 | |
92 | - $this->app->singleton(Utils\CacheTag::class, function () { |
|
92 | + $this->app->singleton(Utils\CacheTag::class, function() { |
|
93 | 93 | return new Utils\CacheTag(); |
94 | 94 | }); |
95 | 95 | |
96 | - $this->app->singleton(Utils\WidgetRenderer::class, function () { |
|
96 | + $this->app->singleton(Utils\WidgetRenderer::class, function() { |
|
97 | 97 | return new Utils\WidgetRenderer(); |
98 | 98 | }); |
99 | 99 | } |
100 | 100 | |
101 | 101 | private function _registerMacros() |
102 | 102 | { |
103 | - Route::macro('view', function ($url, $view, $name = null) { |
|
103 | + Route::macro('view', function($url, $view, $name = null) { |
|
104 | 104 | return Route::get($url, [ |
105 | 105 | 'as' => $name, |
106 | - 'uses' => function () use ($view) { |
|
106 | + 'uses' => function() use ($view) { |
|
107 | 107 | return view($view); |
108 | 108 | }, |
109 | 109 | ]); |
110 | 110 | }); |
111 | 111 | |
112 | - Route::macro('widget', function ($url, $widget, $name = null) { |
|
112 | + Route::macro('widget', function($url, $widget, $name = null) { |
|
113 | 113 | return Route::get($url, [ |
114 | 114 | 'as' => $name, |
115 | - 'uses' => function (...$args) use ($widget) { |
|
115 | + 'uses' => function(...$args) use ($widget) { |
|
116 | 116 | return render_widget($widget, $args); |
117 | 117 | }, |
118 | 118 | ]); |
119 | 119 | }); |
120 | 120 | |
121 | - Route::macro('jsonWidget', function ($url, $widget, $name = null) { |
|
121 | + Route::macro('jsonWidget', function($url, $widget, $name = null) { |
|
122 | 122 | return Route::get($url, [ |
123 | 123 | 'as' => $name, |
124 | - 'uses' => function (...$args) use ($widget) { |
|
124 | + 'uses' => function(...$args) use ($widget) { |
|
125 | 125 | return json_widget($widget, $args); |
126 | 126 | }, |
127 | 127 | ]); |
@@ -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 | /** |