@@ -7,168 +7,168 @@ |
||
7 | 7 | |
8 | 8 | class PackageManifest |
9 | 9 | { |
10 | - /** |
|
11 | - * The filesystem instance. |
|
12 | - * |
|
13 | - * @var \Illuminate\Filesystem\Filesystem |
|
14 | - */ |
|
15 | - public $files; |
|
16 | - |
|
17 | - /** |
|
18 | - * The base path. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $basePath; |
|
23 | - |
|
24 | - /** |
|
25 | - * The vendor path. |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - public $vendorPath; |
|
30 | - |
|
31 | - /** |
|
32 | - * The manifest path. |
|
33 | - * |
|
34 | - * @var string|null |
|
35 | - */ |
|
36 | - public $manifestPath; |
|
37 | - |
|
38 | - /** |
|
39 | - * The loaded manifest array. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - public $manifest; |
|
44 | - |
|
45 | - /** |
|
46 | - * Create a new package manifest instance. |
|
47 | - * |
|
48 | - * @param \Illuminate\Filesystem\Filesystem $files |
|
49 | - * @param string $basePath |
|
50 | - * @param string $manifestPath |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - public function __construct(Filesystem $files, $basePath, $manifestPath) |
|
54 | - { |
|
55 | - $this->files = $files; |
|
56 | - $this->basePath = $basePath; |
|
57 | - $this->manifestPath = $manifestPath; |
|
58 | - $this->vendorPath = $basePath.'/vendor'; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Get all of the integrator class names for all packages. |
|
63 | - * |
|
64 | - * @return array |
|
65 | - */ |
|
66 | - public function joints() |
|
67 | - { |
|
68 | - return collect($this->getManifest())->flatMap(function ($configuration) { |
|
69 | - return (array) ($configuration['joints'] ?? []); |
|
70 | - })->filter()->all(); |
|
71 | - } |
|
10 | + /** |
|
11 | + * The filesystem instance. |
|
12 | + * |
|
13 | + * @var \Illuminate\Filesystem\Filesystem |
|
14 | + */ |
|
15 | + public $files; |
|
16 | + |
|
17 | + /** |
|
18 | + * The base path. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $basePath; |
|
23 | + |
|
24 | + /** |
|
25 | + * The vendor path. |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $vendorPath; |
|
30 | + |
|
31 | + /** |
|
32 | + * The manifest path. |
|
33 | + * |
|
34 | + * @var string|null |
|
35 | + */ |
|
36 | + public $manifestPath; |
|
37 | + |
|
38 | + /** |
|
39 | + * The loaded manifest array. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + public $manifest; |
|
44 | + |
|
45 | + /** |
|
46 | + * Create a new package manifest instance. |
|
47 | + * |
|
48 | + * @param \Illuminate\Filesystem\Filesystem $files |
|
49 | + * @param string $basePath |
|
50 | + * @param string $manifestPath |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + public function __construct(Filesystem $files, $basePath, $manifestPath) |
|
54 | + { |
|
55 | + $this->files = $files; |
|
56 | + $this->basePath = $basePath; |
|
57 | + $this->manifestPath = $manifestPath; |
|
58 | + $this->vendorPath = $basePath.'/vendor'; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Get all of the integrator class names for all packages. |
|
63 | + * |
|
64 | + * @return array |
|
65 | + */ |
|
66 | + public function joints() |
|
67 | + { |
|
68 | + return collect($this->getManifest())->flatMap(function ($configuration) { |
|
69 | + return (array) ($configuration['joints'] ?? []); |
|
70 | + })->filter()->all(); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Get all of the module declared for all packages. |
|
75 | - * |
|
76 | - * @return array |
|
77 | - */ |
|
78 | - public function modules() |
|
79 | - { |
|
80 | - return collect($this->getManifest())->flatMap(function ($configuration, $package) { |
|
81 | - return array_map(function($moduleRelativePath) use ($package) { |
|
82 | - return str_ireplace('/', DIRECTORY_SEPARATOR, implode('/', [$this->vendorPath, $package, $moduleRelativePath])); |
|
83 | - }, (array) ($configuration['modules'] ?? [])); |
|
84 | - })->filter()->all(); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Get the current package manifest. |
|
89 | - * |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - protected function getManifest() |
|
93 | - { |
|
94 | - if (isset($this->manifest)) { |
|
95 | - return $this->manifest; |
|
96 | - } |
|
97 | - |
|
98 | - if (! file_exists($this->manifestPath)) { |
|
99 | - $this->build(); |
|
100 | - } |
|
73 | + /** |
|
74 | + * Get all of the module declared for all packages. |
|
75 | + * |
|
76 | + * @return array |
|
77 | + */ |
|
78 | + public function modules() |
|
79 | + { |
|
80 | + return collect($this->getManifest())->flatMap(function ($configuration, $package) { |
|
81 | + return array_map(function($moduleRelativePath) use ($package) { |
|
82 | + return str_ireplace('/', DIRECTORY_SEPARATOR, implode('/', [$this->vendorPath, $package, $moduleRelativePath])); |
|
83 | + }, (array) ($configuration['modules'] ?? [])); |
|
84 | + })->filter()->all(); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Get the current package manifest. |
|
89 | + * |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + protected function getManifest() |
|
93 | + { |
|
94 | + if (isset($this->manifest)) { |
|
95 | + return $this->manifest; |
|
96 | + } |
|
97 | + |
|
98 | + if (! file_exists($this->manifestPath)) { |
|
99 | + $this->build(); |
|
100 | + } |
|
101 | 101 | |
102 | - return $this->manifest = file_exists($this->manifestPath) ? |
|
103 | - $this->files->getRequire($this->manifestPath) : []; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Build the manifest and write it to disk. |
|
108 | - * |
|
109 | - * @return void |
|
110 | - */ |
|
111 | - public function build() |
|
112 | - { |
|
113 | - $packages = []; |
|
114 | - |
|
115 | - if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { |
|
116 | - $packages = json_decode($this->files->get($path), true); |
|
117 | - } |
|
118 | - |
|
119 | - $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); |
|
120 | - |
|
121 | - $this->write(collect($packages)->mapWithKeys(function ($package) { |
|
122 | - return [$this->format($package['name']) => $package['extra']['epesi'] ?? []]; |
|
123 | - })->each(function ($configuration) use (&$ignore) { |
|
124 | - $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); |
|
125 | - })->reject(function ($configuration, $package) use ($ignore, $ignoreAll) { |
|
126 | - return $ignoreAll || in_array($package, $ignore); |
|
127 | - })->filter()->all()); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Format the given package name. |
|
132 | - * |
|
133 | - * @param string $package |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - protected function format($package) |
|
137 | - { |
|
138 | - return str_replace($this->vendorPath.'/', '', $package); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Get all of the package names that should be ignored. |
|
143 | - * |
|
144 | - * @return array |
|
145 | - */ |
|
146 | - protected function packagesToIgnore() |
|
147 | - { |
|
148 | - if (! file_exists($this->basePath.'/composer.json')) { |
|
149 | - return []; |
|
150 | - } |
|
151 | - |
|
152 | - return json_decode(file_get_contents( |
|
153 | - $this->basePath.'/composer.json' |
|
154 | - ), true)['extra']['epesi']['dont-discover'] ?? []; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Write the given manifest array to disk. |
|
159 | - * |
|
160 | - * @param array $manifest |
|
161 | - * @return void |
|
162 | - * @throws \Exception |
|
163 | - */ |
|
164 | - protected function write(array $manifest) |
|
165 | - { |
|
166 | - if (! is_writable(dirname($this->manifestPath))) { |
|
167 | - throw new Exception('The '.dirname($this->manifestPath).' directory must be present and writable.'); |
|
168 | - } |
|
169 | - |
|
170 | - $this->files->put( |
|
171 | - $this->manifestPath, '<?php return '.var_export($manifest, true).';' |
|
172 | - ); |
|
173 | - } |
|
102 | + return $this->manifest = file_exists($this->manifestPath) ? |
|
103 | + $this->files->getRequire($this->manifestPath) : []; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Build the manifest and write it to disk. |
|
108 | + * |
|
109 | + * @return void |
|
110 | + */ |
|
111 | + public function build() |
|
112 | + { |
|
113 | + $packages = []; |
|
114 | + |
|
115 | + if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { |
|
116 | + $packages = json_decode($this->files->get($path), true); |
|
117 | + } |
|
118 | + |
|
119 | + $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); |
|
120 | + |
|
121 | + $this->write(collect($packages)->mapWithKeys(function ($package) { |
|
122 | + return [$this->format($package['name']) => $package['extra']['epesi'] ?? []]; |
|
123 | + })->each(function ($configuration) use (&$ignore) { |
|
124 | + $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); |
|
125 | + })->reject(function ($configuration, $package) use ($ignore, $ignoreAll) { |
|
126 | + return $ignoreAll || in_array($package, $ignore); |
|
127 | + })->filter()->all()); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Format the given package name. |
|
132 | + * |
|
133 | + * @param string $package |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + protected function format($package) |
|
137 | + { |
|
138 | + return str_replace($this->vendorPath.'/', '', $package); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Get all of the package names that should be ignored. |
|
143 | + * |
|
144 | + * @return array |
|
145 | + */ |
|
146 | + protected function packagesToIgnore() |
|
147 | + { |
|
148 | + if (! file_exists($this->basePath.'/composer.json')) { |
|
149 | + return []; |
|
150 | + } |
|
151 | + |
|
152 | + return json_decode(file_get_contents( |
|
153 | + $this->basePath.'/composer.json' |
|
154 | + ), true)['extra']['epesi']['dont-discover'] ?? []; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Write the given manifest array to disk. |
|
159 | + * |
|
160 | + * @param array $manifest |
|
161 | + * @return void |
|
162 | + * @throws \Exception |
|
163 | + */ |
|
164 | + protected function write(array $manifest) |
|
165 | + { |
|
166 | + if (! is_writable(dirname($this->manifestPath))) { |
|
167 | + throw new Exception('The '.dirname($this->manifestPath).' directory must be present and writable.'); |
|
168 | + } |
|
169 | + |
|
170 | + $this->files->put( |
|
171 | + $this->manifestPath, '<?php return '.var_export($manifest, true).';' |
|
172 | + ); |
|
173 | + } |
|
174 | 174 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $this->files = $files; |
56 | 56 | $this->basePath = $basePath; |
57 | 57 | $this->manifestPath = $manifestPath; |
58 | - $this->vendorPath = $basePath.'/vendor'; |
|
58 | + $this->vendorPath = $basePath . '/vendor'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function joints() |
67 | 67 | { |
68 | - return collect($this->getManifest())->flatMap(function ($configuration) { |
|
68 | + return collect($this->getManifest())->flatMap(function($configuration) { |
|
69 | 69 | return (array) ($configuration['joints'] ?? []); |
70 | 70 | })->filter()->all(); |
71 | 71 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function modules() |
79 | 79 | { |
80 | - return collect($this->getManifest())->flatMap(function ($configuration, $package) { |
|
80 | + return collect($this->getManifest())->flatMap(function($configuration, $package) { |
|
81 | 81 | return array_map(function($moduleRelativePath) use ($package) { |
82 | 82 | return str_ireplace('/', DIRECTORY_SEPARATOR, implode('/', [$this->vendorPath, $package, $moduleRelativePath])); |
83 | 83 | }, (array) ($configuration['modules'] ?? [])); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | return $this->manifest; |
96 | 96 | } |
97 | 97 | |
98 | - if (! file_exists($this->manifestPath)) { |
|
98 | + if (!file_exists($this->manifestPath)) { |
|
99 | 99 | $this->build(); |
100 | 100 | } |
101 | 101 | |
@@ -112,17 +112,17 @@ discard block |
||
112 | 112 | { |
113 | 113 | $packages = []; |
114 | 114 | |
115 | - if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { |
|
115 | + if ($this->files->exists($path = $this->vendorPath . '/composer/installed.json')) { |
|
116 | 116 | $packages = json_decode($this->files->get($path), true); |
117 | 117 | } |
118 | 118 | |
119 | 119 | $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); |
120 | 120 | |
121 | - $this->write(collect($packages)->mapWithKeys(function ($package) { |
|
121 | + $this->write(collect($packages)->mapWithKeys(function($package) { |
|
122 | 122 | return [$this->format($package['name']) => $package['extra']['epesi'] ?? []]; |
123 | - })->each(function ($configuration) use (&$ignore) { |
|
123 | + })->each(function($configuration) use (&$ignore) { |
|
124 | 124 | $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); |
125 | - })->reject(function ($configuration, $package) use ($ignore, $ignoreAll) { |
|
125 | + })->reject(function($configuration, $package) use ($ignore, $ignoreAll) { |
|
126 | 126 | return $ignoreAll || in_array($package, $ignore); |
127 | 127 | })->filter()->all()); |
128 | 128 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function format($package) |
137 | 137 | { |
138 | - return str_replace($this->vendorPath.'/', '', $package); |
|
138 | + return str_replace($this->vendorPath . '/', '', $package); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function packagesToIgnore() |
147 | 147 | { |
148 | - if (! file_exists($this->basePath.'/composer.json')) { |
|
148 | + if (!file_exists($this->basePath . '/composer.json')) { |
|
149 | 149 | return []; |
150 | 150 | } |
151 | 151 | |
152 | 152 | return json_decode(file_get_contents( |
153 | - $this->basePath.'/composer.json' |
|
153 | + $this->basePath . '/composer.json' |
|
154 | 154 | ), true)['extra']['epesi']['dont-discover'] ?? []; |
155 | 155 | } |
156 | 156 | |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function write(array $manifest) |
165 | 165 | { |
166 | - if (! is_writable(dirname($this->manifestPath))) { |
|
167 | - throw new Exception('The '.dirname($this->manifestPath).' directory must be present and writable.'); |
|
166 | + if (!is_writable(dirname($this->manifestPath))) { |
|
167 | + throw new Exception('The ' . dirname($this->manifestPath) . ' directory must be present and writable.'); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $this->files->put( |
171 | - $this->manifestPath, '<?php return '.var_export($manifest, true).';' |
|
171 | + $this->manifestPath, '<?php return ' . var_export($manifest, true) . ';' |
|
172 | 172 | ); |
173 | 173 | } |
174 | 174 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | $joint = new $class(); |
26 | 26 | |
27 | - if (! $joint->access()) continue; |
|
27 | + if (!$joint->access()) continue; |
|
28 | 28 | |
29 | 29 | $ret->add($joint); |
30 | 30 | } |
@@ -29,7 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | $joint = new $class(); |
31 | 31 | |
32 | - if (! $joint->access()) continue; |
|
32 | + if (! $joint->access()) { |
|
33 | + continue; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | $ret->add($joint); |
35 | 37 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | */ |
15 | 15 | final public static function view($alias = null) |
16 | 16 | { |
17 | - $class = self::namespace() . '\\' . ($alias? Str::studly($alias): (static::name() . 'View')); |
|
17 | + $class = self::namespace() . '\\' . ($alias ? Str::studly($alias) : (static::name() . 'View')); |
|
18 | 18 | |
19 | 19 | if ($alias) return $class; |
20 | 20 | |
21 | - return static::$view?: $class; |
|
21 | + return static::$view ?: $class; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $names = array_slice(explode('\\', static::class), -2, -1); |
67 | 67 | |
68 | - return $names? reset($names): ''; |
|
68 | + return $names ? reset($names) : ''; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -16,7 +16,9 @@ |
||
16 | 16 | { |
17 | 17 | $class = self::namespace() . '\\' . ($alias? Str::studly($alias): (static::name() . 'View')); |
18 | 18 | |
19 | - if ($alias) return $class; |
|
19 | + if ($alias) { |
|
20 | + return $class; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | return static::$view?: $class; |
22 | 24 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | { |
34 | 34 | $link = $this->link(); |
35 | 35 | |
36 | - $link = is_array($link)? ModuleView::moduleLink(...$link): $link; |
|
36 | + $link = is_array($link) ? ModuleView::moduleLink(...$link) : $link; |
|
37 | 37 | |
38 | 38 | return (new LaunchButton([ |
39 | 39 | 'label' => $this->label(), |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | final public static function packageManifest() |
13 | 13 | { |
14 | - return self::$packageManifest = self::$packageManifest?: new PackageManifest(new Filesystem(), app()->basePath(), self::getCachedManifestPath()); |
|
14 | + return self::$packageManifest = self::$packageManifest ?: new PackageManifest(new Filesystem(), app()->basePath(), self::getCachedManifestPath()); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | final public static function getCachedManifestPath() |
@@ -4,24 +4,24 @@ |
||
4 | 4 | |
5 | 5 | trait Notifies |
6 | 6 | { |
7 | - public function notify($options) |
|
8 | - { |
|
9 | - $options = array_merge(['duration'=> 1500], is_array($options)? $options: ['message' => $options]); |
|
7 | + public function notify($options) |
|
8 | + { |
|
9 | + $options = array_merge(['duration'=> 1500], is_array($options)? $options: ['message' => $options]); |
|
10 | 10 | |
11 | - return new \atk4\ui\jsToast($options); |
|
12 | - } |
|
11 | + return new \atk4\ui\jsToast($options); |
|
12 | + } |
|
13 | 13 | |
14 | - public function notifySuccess($options) |
|
15 | - { |
|
16 | - $options = array_merge(['class' => 'success'], is_array($options)? $options: ['message' => $options]); |
|
14 | + public function notifySuccess($options) |
|
15 | + { |
|
16 | + $options = array_merge(['class' => 'success'], is_array($options)? $options: ['message' => $options]); |
|
17 | 17 | |
18 | - return $this->notify($options); |
|
19 | - } |
|
18 | + return $this->notify($options); |
|
19 | + } |
|
20 | 20 | |
21 | - public function notifyError($options) |
|
22 | - { |
|
23 | - $options = array_merge(['class' => 'error'], is_array($options)? $options: ['message' => $options]); |
|
21 | + public function notifyError($options) |
|
22 | + { |
|
23 | + $options = array_merge(['class' => 'error'], is_array($options)? $options: ['message' => $options]); |
|
24 | 24 | |
25 | - return $this->notify($options); |
|
26 | - } |
|
25 | + return $this->notify($options); |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -6,21 +6,21 @@ |
||
6 | 6 | { |
7 | 7 | public function notify($options) |
8 | 8 | { |
9 | - $options = array_merge(['duration'=> 1500], is_array($options)? $options: ['message' => $options]); |
|
9 | + $options = array_merge(['duration'=> 1500], is_array($options) ? $options : ['message' => $options]); |
|
10 | 10 | |
11 | 11 | return new \atk4\ui\jsToast($options); |
12 | 12 | } |
13 | 13 | |
14 | 14 | public function notifySuccess($options) |
15 | 15 | { |
16 | - $options = array_merge(['class' => 'success'], is_array($options)? $options: ['message' => $options]); |
|
16 | + $options = array_merge(['class' => 'success'], is_array($options) ? $options : ['message' => $options]); |
|
17 | 17 | |
18 | 18 | return $this->notify($options); |
19 | 19 | } |
20 | 20 | |
21 | 21 | public function notifyError($options) |
22 | 22 | { |
23 | - $options = array_merge(['class' => 'error'], is_array($options)? $options: ['message' => $options]); |
|
23 | + $options = array_merge(['class' => 'error'], is_array($options) ? $options : ['message' => $options]); |
|
24 | 24 | |
25 | 25 | return $this->notify($options); |
26 | 26 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | $paths = $this->migrations(); |
22 | 22 | |
23 | - foreach (is_array($paths)? $paths: [$paths] as $path) { |
|
23 | + foreach (is_array($paths) ? $paths : [$paths] as $path) { |
|
24 | 24 | \Illuminate\Support\Facades\Artisan::call('migrate', ['--path' => $path, '--force' => true]); |
25 | 25 | } |
26 | 26 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $paths = $this->migrations(); |
33 | 33 | |
34 | - foreach (is_array($paths)? $paths: [$paths] as $path) { |
|
34 | + foreach (is_array($paths) ? $paths : [$paths] as $path) { |
|
35 | 35 | \Illuminate\Support\Facades\Artisan::call('migrate:rollback', ['--path' => $path]); |
36 | 36 | } |
37 | 37 |
@@ -48,8 +48,8 @@ |
||
48 | 48 | $alias = class_exists($module)? $module::alias(): $module; |
49 | 49 | |
50 | 50 | if (is_array($method) && !$args) { |
51 | - $args = $method; |
|
52 | - $method = 'body'; |
|
51 | + $args = $method; |
|
52 | + $method = 'body'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return url(implode('/', ['view', $alias, $method, self::encodeArgs($args)])); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | { |
22 | 22 | $defaultView = self::module()::view(); |
23 | 23 | |
24 | - $viewClass = is_a(static::class, ModuleView::class, true)? static::class: $defaultView; |
|
24 | + $viewClass = is_a(static::class, ModuleView::class, true) ? static::class : $defaultView; |
|
25 | 25 | |
26 | 26 | $viewAlias = null; |
27 | 27 | if ($viewClass !== $defaultView) { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | final public static function moduleLink($module, $method = 'body', $args = []) |
47 | 47 | { |
48 | - $alias = class_exists($module)? $module::alias(): $module; |
|
48 | + $alias = class_exists($module) ? $module::alias() : $module; |
|
49 | 49 | |
50 | 50 | if (is_array($method) && !$args) { |
51 | 51 | $args = $method; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
65 | 65 | */ |
66 | 66 | final public static function decodeArgs($hash) { |
67 | - if (! $hash) return []; |
|
67 | + if (!$hash) return []; |
|
68 | 68 | |
69 | 69 | $args = session($hash); |
70 | 70 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | final public static function encodeArgs($args) { |
83 | 83 | $args = (array) $args; |
84 | 84 | |
85 | - if (! $args) return; |
|
85 | + if (!$args) return; |
|
86 | 86 | |
87 | 87 | $hash = md5(serialize($args)); |
88 | 88 |
@@ -64,11 +64,15 @@ discard block |
||
64 | 64 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
65 | 65 | */ |
66 | 66 | final public static function decodeArgs($hash) { |
67 | - if (! $hash) return []; |
|
67 | + if (! $hash) { |
|
68 | + return []; |
|
69 | + } |
|
68 | 70 | |
69 | 71 | $args = session($hash); |
70 | 72 | |
71 | - if (is_null($args)) abort(419); |
|
73 | + if (is_null($args)) { |
|
74 | + abort(419); |
|
75 | + } |
|
72 | 76 | |
73 | 77 | return (array) $args; |
74 | 78 | } |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | final public static function encodeArgs($args) { |
83 | 87 | $args = (array) $args; |
84 | 88 | |
85 | - if (! $args) return; |
|
89 | + if (! $args) { |
|
90 | + return; |
|
91 | + } |
|
86 | 92 | |
87 | 93 | $hash = md5(serialize($args)); |
88 | 94 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | return self::$installed = self::$installed?? self::getCached('epesi-modules-installed', function() { |
66 | 66 | try { |
67 | - $installedModules = Module::pluck('class', 'alias'); |
|
67 | + $installedModules = Module::pluck('class', 'alias'); |
|
68 | 68 | } catch (\Exception $e) { |
69 | 69 | $installedModules = collect(); |
70 | 70 | } |
@@ -104,27 +104,27 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected static function discoverModuleClasses($namespace, $basePath) |
106 | 106 | { |
107 | - $ret = collect(); |
|
107 | + $ret = collect(); |
|
108 | 108 | |
109 | - $moduleNamespace = trim($namespace, '\\'); |
|
109 | + $moduleNamespace = trim($namespace, '\\'); |
|
110 | 110 | |
111 | - $names = array_slice(explode('\\', $moduleNamespace), - 1); |
|
111 | + $names = array_slice(explode('\\', $moduleNamespace), - 1); |
|
112 | 112 | |
113 | - if ($name = $names? reset($names): '') { |
|
114 | - $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
|
113 | + if ($name = $names? reset($names): '') { |
|
114 | + $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
|
115 | 115 | |
116 | - if (is_subclass_of($moduleClass, ModuleCore::class)) { |
|
117 | - $ret->add($moduleClass); |
|
118 | - } |
|
119 | - } |
|
116 | + if (is_subclass_of($moduleClass, ModuleCore::class)) { |
|
117 | + $ret->add($moduleClass); |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | - foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
122 | - $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
|
121 | + foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
122 | + $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
|
123 | 123 | |
124 | - $ret = $ret->merge(self::discoverModuleClasses($subModuleNamespace, $path)); |
|
125 | - } |
|
124 | + $ret = $ret->merge(self::discoverModuleClasses($subModuleNamespace, $path)); |
|
125 | + } |
|
126 | 126 | |
127 | - return $ret; |
|
127 | + return $ret; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -356,7 +356,6 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @param string $classOrAlias |
358 | 358 | * @throws \Exception |
359 | - |
|
360 | 359 | * @return boolean |
361 | 360 | */ |
362 | 361 | public static function uninstall($classOrAlias) |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public static function isInstalled($classOrAlias) |
28 | 28 | { |
29 | - return self::getClass($classOrAlias, true)? 1: 0; |
|
29 | + return self::getClass($classOrAlias, true) ? 1 : 0; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return string; |
49 | 49 | */ |
50 | 50 | public static function getClass($classOrAlias, $installedOnly = false) { |
51 | - $modules = $installedOnly? self::getInstalled(): self::getAll(); |
|
51 | + $modules = $installedOnly ? self::getInstalled() : self::getAll(); |
|
52 | 52 | |
53 | 53 | if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
54 | 54 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function getAll() |
82 | 82 | { |
83 | - return self::getCached('epesi-modules-available', function () { |
|
83 | + return self::getCached('epesi-modules-available', function() { |
|
84 | 84 | $modules = collect(); |
85 | - foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules()?: []) as $namespace => $path) { |
|
85 | + foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules() ?: []) as $namespace => $path) { |
|
86 | 86 | foreach (self::discoverModuleClasses($namespace, $path) as $moduleClass) { |
87 | 87 | $modules->add(['alias' => $moduleClass::alias(), 'class' => $moduleClass]); |
88 | 88 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $names = array_slice(explode('\\', $moduleNamespace), - 1); |
112 | 112 | |
113 | - if ($name = $names? reset($names): '') { |
|
113 | + if ($name = $names ? reset($names) : '') { |
|
114 | 114 | $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
115 | 115 | |
116 | 116 | if (is_subclass_of($moduleClass, ModuleCore::class)) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | - foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
121 | + foreach (glob($basePath . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $path) { |
|
122 | 122 | $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
123 | 123 | |
124 | 124 | $ret = $ret->merge(self::discoverModuleClasses($subModuleNamespace, $path)); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | protected static function getCached($key, \Closure $default) |
138 | 138 | { |
139 | - if (! Cache::has($key)) { |
|
139 | + if (!Cache::has($key)) { |
|
140 | 140 | Cache::forever($key, $default()); |
141 | 141 | } |
142 | 142 | |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public static function collect($method, $args = []) |
176 | 176 | { |
177 | - $args = is_array($args)? $args: [$args]; |
|
177 | + $args = is_array($args) ? $args : [$args]; |
|
178 | 178 | |
179 | 179 | $installedModules = self::getInstalled(); |
180 | 180 | |
181 | 181 | // if epesi is not installed fake having the system module to enable its functionality |
182 | - if (! $installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
182 | + if (!$installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
183 | 183 | $installedModules = collect([ |
184 | 184 | 'system' => \Epesi\Core\System\SystemCore::class |
185 | 185 | ]); |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | |
188 | 188 | $ret = []; |
189 | 189 | foreach ($installedModules as $module) { |
190 | - if (! $list = $module::$method(...$args)) continue; |
|
190 | + if (!$list = $module::$method(...$args)) continue; |
|
191 | 191 | |
192 | - $ret = array_merge($ret, is_array($list)? $list: [$list]); |
|
192 | + $ret = array_merge($ret, is_array($list) ? $list : [$list]); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | return $ret; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | return true; |
209 | 209 | } |
210 | 210 | |
211 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
211 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
212 | 212 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
213 | 213 | } |
214 | 214 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | ]); |
239 | 239 | |
240 | 240 | if ($installRecommended) { |
241 | - $installRecommended = is_array($installRecommended)? $installRecommended: $module->recommended(); |
|
241 | + $installRecommended = is_array($installRecommended) ? $installRecommended : $module->recommended(); |
|
242 | 242 | |
243 | 243 | foreach ($installRecommended as $recommendedModule) { |
244 | 244 | try { |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | $parentModule = array_shift($unsatisfiedDependencies); |
272 | 272 | |
273 | 273 | if (self::$processing[$parentModule]?? false) { |
274 | - throw new \Exception('Cross dependency: '. $parentModule); |
|
274 | + throw new \Exception('Cross dependency: ' . $parentModule); |
|
275 | 275 | } |
276 | 276 | |
277 | - if (! self::isAvailable($parentModule)) { |
|
277 | + if (!self::isAvailable($parentModule)) { |
|
278 | 278 | throw new \Exception('Module not found: "' . $parentModule . '"'); |
279 | 279 | } |
280 | 280 | |
@@ -361,13 +361,13 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function uninstall($classOrAlias) |
363 | 363 | { |
364 | - if (! self::isInstalled($classOrAlias)) { |
|
364 | + if (!self::isInstalled($classOrAlias)) { |
|
365 | 365 | print ('Module "' . $classOrAlias . '" is not installed!'); |
366 | 366 | |
367 | 367 | return true; |
368 | 368 | } |
369 | 369 | |
370 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
370 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
371 | 371 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
372 | 372 | } |
373 | 373 |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | public static function getClass($classOrAlias, $installedOnly = false) { |
37 | 37 | $modules = $installedOnly? self::getInstalled(): self::getAll(); |
38 | 38 | |
39 | - if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
|
39 | + if (collect($modules)->contains($classOrAlias)) { |
|
40 | + return $classOrAlias; |
|
41 | + } |
|
40 | 42 | |
41 | 43 | return $modules[$classOrAlias]?? null; |
42 | 44 | } |
@@ -138,7 +140,9 @@ discard block |
||
138 | 140 | |
139 | 141 | $ret = []; |
140 | 142 | foreach ($installedModules as $module) { |
141 | - if (! $list = $module::$method(...$args)) continue; |
|
143 | + if (! $list = $module::$method(...$args)) { |
|
144 | + continue; |
|
145 | + } |
|
142 | 146 | |
143 | 147 | $ret = array_merge($ret, is_array($list)? $list: [$list]); |
144 | 148 | } |