@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public static function isInstalled($classOrAlias) |
| 20 | 20 | { |
| 21 | - return self::getClass($classOrAlias)? 1: 0; |
|
| 21 | + return self::getClass($classOrAlias) ? 1 : 0; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public static function isAvalable($classOrAlias) |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @return string; |
| 34 | 34 | */ |
| 35 | 35 | public static function getClass($classOrAlias, $installed = false) { |
| 36 | - $allModules = $installed? self::getInstalled(): self::getAll(); |
|
| 36 | + $allModules = $installed ? self::getInstalled() : self::getAll(); |
|
| 37 | 37 | |
| 38 | 38 | if (collect($allModules)->contains($classOrAlias)) return $classOrAlias; |
| 39 | 39 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | public static function getInstalled() |
| 49 | 49 | { |
| 50 | 50 | return self::$installed = self::$installed?? self::getCached('epesi-modules-installed', function() { |
| 51 | - $installedModules = Schema::hasTable('modules')? Module::pluck('class', 'alias'): collect(); |
|
| 51 | + $installedModules = Schema::hasTable('modules') ? Module::pluck('class', 'alias') : collect(); |
|
| 52 | 52 | |
| 53 | 53 | // if epesi is not installed fake having the system module to enable its functionality |
| 54 | 54 | if ($installedModules->isEmpty()) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public static function getAll() |
| 68 | 68 | { |
| 69 | - return self::getCached('epesi-modules-available', function () { |
|
| 69 | + return self::getCached('epesi-modules-available', function() { |
|
| 70 | 70 | $modules = collect(); |
| 71 | 71 | foreach (array_merge(config('epesi.modules'), self::packageManifest()->modules()) as $moduleClass) { |
| 72 | 72 | $modules->add(['alias' => $moduleClass::alias(), 'class' => $moduleClass]); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | protected static function getCached($key, \Closure $default) |
| 87 | 87 | { |
| 88 | - if (! Cache::has($key)) { |
|
| 88 | + if (!Cache::has($key)) { |
|
| 89 | 89 | Cache::forever($key, $default()); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public static function collect($method, $args = []) |
| 111 | 111 | { |
| 112 | - $args = is_array($args)? $args: [$args]; |
|
| 112 | + $args = is_array($args) ? $args : [$args]; |
|
| 113 | 113 | |
| 114 | 114 | $ret = []; |
| 115 | 115 | foreach (self::getInstalled() as $module) { |
| 116 | - if (! $list = $module::$method(...$args)) continue; |
|
| 116 | + if (!$list = $module::$method(...$args)) continue; |
|
| 117 | 117 | |
| 118 | - $ret = array_merge($ret, is_array($list)? $list: [$list]); |
|
| 118 | + $ret = array_merge($ret, is_array($list) ? $list : [$list]); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | return $ret; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | return true; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 137 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 138 | 138 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | $parentModule = $unsatisfiedDependencies[0]; |
| 187 | 187 | |
| 188 | 188 | if (self::$processing[$moduleClass]?? false) { |
| 189 | - throw new \Exception('Cross dependency: '. $moduleClass); |
|
| 189 | + throw new \Exception('Cross dependency: ' . $moduleClass); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if (! self::isAvalable($parentModule)) { |
|
| 192 | + if (!self::isAvalable($parentModule)) { |
|
| 193 | 193 | throw new \Exception('Module not found: "' . $parentModule . '"'); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | public static function getClass($classOrAlias, $installed = false) { |
| 36 | 36 | $allModules = $installed? self::getInstalled(): self::getAll(); |
| 37 | 37 | |
| 38 | - if (collect($allModules)->contains($classOrAlias)) return $classOrAlias; |
|
| 38 | + if (collect($allModules)->contains($classOrAlias)) { |
|
| 39 | + return $classOrAlias; |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | return $allModules[$classOrAlias]?? null; |
| 41 | 43 | } |
@@ -113,7 +115,9 @@ discard block |
||
| 113 | 115 | |
| 114 | 116 | $ret = []; |
| 115 | 117 | foreach (self::getInstalled() as $module) { |
| 116 | - if (! $list = $module::$method(...$args)) continue; |
|
| 118 | + if (! $list = $module::$method(...$args)) { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 117 | 121 | |
| 118 | 122 | $ret = array_merge($ret, is_array($list)? $list: [$list]); |
| 119 | 123 | } |
@@ -7,166 +7,166 @@ |
||
| 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) { |
|
| 81 | - return (array) ($configuration['modules'] ?? []); |
|
| 82 | - })->filter()->all(); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Get the current package manifest. |
|
| 87 | - * |
|
| 88 | - * @return array |
|
| 89 | - */ |
|
| 90 | - protected function getManifest() |
|
| 91 | - { |
|
| 92 | - if (isset($this->manifest)) { |
|
| 93 | - return $this->manifest; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if (! file_exists($this->manifestPath)) { |
|
| 97 | - $this->build(); |
|
| 98 | - } |
|
| 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) { |
|
| 81 | + return (array) ($configuration['modules'] ?? []); |
|
| 82 | + })->filter()->all(); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Get the current package manifest. |
|
| 87 | + * |
|
| 88 | + * @return array |
|
| 89 | + */ |
|
| 90 | + protected function getManifest() |
|
| 91 | + { |
|
| 92 | + if (isset($this->manifest)) { |
|
| 93 | + return $this->manifest; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if (! file_exists($this->manifestPath)) { |
|
| 97 | + $this->build(); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - return $this->manifest = file_exists($this->manifestPath) ? |
|
| 101 | - $this->files->getRequire($this->manifestPath) : []; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Build the manifest and write it to disk. |
|
| 106 | - * |
|
| 107 | - * @return void |
|
| 108 | - */ |
|
| 109 | - public function build() |
|
| 110 | - { |
|
| 111 | - $packages = []; |
|
| 112 | - |
|
| 113 | - if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { |
|
| 114 | - $packages = json_decode($this->files->get($path), true); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); |
|
| 118 | - |
|
| 119 | - $this->write(collect($packages)->mapWithKeys(function ($package) { |
|
| 120 | - return [$this->format($package['name']) => $package['extra']['epesi'] ?? []]; |
|
| 121 | - })->each(function ($configuration) use (&$ignore) { |
|
| 122 | - $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); |
|
| 123 | - })->reject(function ($configuration, $package) use ($ignore, $ignoreAll) { |
|
| 124 | - return $ignoreAll || in_array($package, $ignore); |
|
| 125 | - })->filter()->all()); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * Format the given package name. |
|
| 130 | - * |
|
| 131 | - * @param string $package |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - protected function format($package) |
|
| 135 | - { |
|
| 136 | - return str_replace($this->vendorPath.'/', '', $package); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Get all of the package names that should be ignored. |
|
| 141 | - * |
|
| 142 | - * @return array |
|
| 143 | - */ |
|
| 144 | - protected function packagesToIgnore() |
|
| 145 | - { |
|
| 146 | - if (! file_exists($this->basePath.'/composer.json')) { |
|
| 147 | - return []; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - return json_decode(file_get_contents( |
|
| 151 | - $this->basePath.'/composer.json' |
|
| 152 | - ), true)['extra']['epesi']['dont-discover'] ?? []; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Write the given manifest array to disk. |
|
| 157 | - * |
|
| 158 | - * @param array $manifest |
|
| 159 | - * @return void |
|
| 160 | - * @throws \Exception |
|
| 161 | - */ |
|
| 162 | - protected function write(array $manifest) |
|
| 163 | - { |
|
| 164 | - if (! is_writable(dirname($this->manifestPath))) { |
|
| 165 | - throw new Exception('The '.dirname($this->manifestPath).' directory must be present and writable.'); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - $this->files->put( |
|
| 169 | - $this->manifestPath, '<?php return '.var_export($manifest, true).';' |
|
| 170 | - ); |
|
| 171 | - } |
|
| 100 | + return $this->manifest = file_exists($this->manifestPath) ? |
|
| 101 | + $this->files->getRequire($this->manifestPath) : []; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Build the manifest and write it to disk. |
|
| 106 | + * |
|
| 107 | + * @return void |
|
| 108 | + */ |
|
| 109 | + public function build() |
|
| 110 | + { |
|
| 111 | + $packages = []; |
|
| 112 | + |
|
| 113 | + if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { |
|
| 114 | + $packages = json_decode($this->files->get($path), true); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); |
|
| 118 | + |
|
| 119 | + $this->write(collect($packages)->mapWithKeys(function ($package) { |
|
| 120 | + return [$this->format($package['name']) => $package['extra']['epesi'] ?? []]; |
|
| 121 | + })->each(function ($configuration) use (&$ignore) { |
|
| 122 | + $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); |
|
| 123 | + })->reject(function ($configuration, $package) use ($ignore, $ignoreAll) { |
|
| 124 | + return $ignoreAll || in_array($package, $ignore); |
|
| 125 | + })->filter()->all()); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Format the given package name. |
|
| 130 | + * |
|
| 131 | + * @param string $package |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + protected function format($package) |
|
| 135 | + { |
|
| 136 | + return str_replace($this->vendorPath.'/', '', $package); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Get all of the package names that should be ignored. |
|
| 141 | + * |
|
| 142 | + * @return array |
|
| 143 | + */ |
|
| 144 | + protected function packagesToIgnore() |
|
| 145 | + { |
|
| 146 | + if (! file_exists($this->basePath.'/composer.json')) { |
|
| 147 | + return []; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + return json_decode(file_get_contents( |
|
| 151 | + $this->basePath.'/composer.json' |
|
| 152 | + ), true)['extra']['epesi']['dont-discover'] ?? []; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Write the given manifest array to disk. |
|
| 157 | + * |
|
| 158 | + * @param array $manifest |
|
| 159 | + * @return void |
|
| 160 | + * @throws \Exception |
|
| 161 | + */ |
|
| 162 | + protected function write(array $manifest) |
|
| 163 | + { |
|
| 164 | + if (! is_writable(dirname($this->manifestPath))) { |
|
| 165 | + throw new Exception('The '.dirname($this->manifestPath).' directory must be present and writable.'); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + $this->files->put( |
|
| 169 | + $this->manifestPath, '<?php return '.var_export($manifest, true).';' |
|
| 170 | + ); |
|
| 171 | + } |
|
| 172 | 172 | } |
@@ -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) { |
|
| 80 | + return collect($this->getManifest())->flatMap(function($configuration) { |
|
| 81 | 81 | return (array) ($configuration['modules'] ?? []); |
| 82 | 82 | })->filter()->all(); |
| 83 | 83 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | return $this->manifest; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if (! file_exists($this->manifestPath)) { |
|
| 96 | + if (!file_exists($this->manifestPath)) { |
|
| 97 | 97 | $this->build(); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -110,17 +110,17 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $packages = []; |
| 112 | 112 | |
| 113 | - if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { |
|
| 113 | + if ($this->files->exists($path = $this->vendorPath . '/composer/installed.json')) { |
|
| 114 | 114 | $packages = json_decode($this->files->get($path), true); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); |
| 118 | 118 | |
| 119 | - $this->write(collect($packages)->mapWithKeys(function ($package) { |
|
| 119 | + $this->write(collect($packages)->mapWithKeys(function($package) { |
|
| 120 | 120 | return [$this->format($package['name']) => $package['extra']['epesi'] ?? []]; |
| 121 | - })->each(function ($configuration) use (&$ignore) { |
|
| 121 | + })->each(function($configuration) use (&$ignore) { |
|
| 122 | 122 | $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); |
| 123 | - })->reject(function ($configuration, $package) use ($ignore, $ignoreAll) { |
|
| 123 | + })->reject(function($configuration, $package) use ($ignore, $ignoreAll) { |
|
| 124 | 124 | return $ignoreAll || in_array($package, $ignore); |
| 125 | 125 | })->filter()->all()); |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | protected function format($package) |
| 135 | 135 | { |
| 136 | - return str_replace($this->vendorPath.'/', '', $package); |
|
| 136 | + return str_replace($this->vendorPath . '/', '', $package); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | protected function packagesToIgnore() |
| 145 | 145 | { |
| 146 | - if (! file_exists($this->basePath.'/composer.json')) { |
|
| 146 | + if (!file_exists($this->basePath . '/composer.json')) { |
|
| 147 | 147 | return []; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | return json_decode(file_get_contents( |
| 151 | - $this->basePath.'/composer.json' |
|
| 151 | + $this->basePath . '/composer.json' |
|
| 152 | 152 | ), true)['extra']['epesi']['dont-discover'] ?? []; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function write(array $manifest) |
| 163 | 163 | { |
| 164 | - if (! is_writable(dirname($this->manifestPath))) { |
|
| 165 | - throw new Exception('The '.dirname($this->manifestPath).' directory must be present and writable.'); |
|
| 164 | + if (!is_writable(dirname($this->manifestPath))) { |
|
| 165 | + throw new Exception('The ' . dirname($this->manifestPath) . ' directory must be present and writable.'); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $this->files->put( |
| 169 | - $this->manifestPath, '<?php return '.var_export($manifest, true).';' |
|
| 169 | + $this->manifestPath, '<?php return ' . var_export($manifest, true) . ';' |
|
| 170 | 170 | ); |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -34,10 +34,10 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | final public function displayModuleContent($method, $args) { |
| 36 | 36 | // if method not callbale abort to 'not found' |
| 37 | - if (! is_callable([$this, $method])) abort(404); |
|
| 37 | + if (!is_callable([$this, $method])) abort(404); |
|
| 38 | 38 | |
| 39 | 39 | // if user has no access abort 'no access' |
| 40 | - if (! $this->access()) abort(401); |
|
| 40 | + if (!$this->access()) abort(401); |
|
| 41 | 41 | |
| 42 | 42 | $args = $this->decodeArgs($args); |
| 43 | 43 | |
@@ -34,10 +34,14 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | final public function displayModuleContent($method, $args) { |
| 36 | 36 | // if method not callbale abort to 'not found' |
| 37 | - if (! is_callable([$this, $method])) abort(404); |
|
| 37 | + if (! is_callable([$this, $method])) { |
|
| 38 | + abort(404); |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | // if user has no access abort 'no access' |
| 40 | - if (! $this->access()) abort(401); |
|
| 42 | + if (! $this->access()) { |
|
| 43 | + abort(401); |
|
| 44 | + } |
|
| 41 | 45 | |
| 42 | 46 | $args = $this->decodeArgs($args); |
| 43 | 47 | |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $templatesDir = static::path() . DIRECTORY_SEPARATOR . 'Templates'; |
| 48 | 48 | |
| 49 | - if (! is_dir($templatesDir)) return; |
|
| 49 | + if (!is_dir($templatesDir)) return; |
|
| 50 | 50 | |
| 51 | 51 | $skinDir = $templatesDir . DIRECTORY_SEPARATOR . $skin; |
| 52 | 52 | |
| 53 | - return is_dir($skinDir)? $skinDir: $templatesDir; |
|
| 53 | + return is_dir($skinDir) ? $skinDir : $templatesDir; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public static function translations() |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $paths = $this->migrations(); |
| 90 | 90 | |
| 91 | - foreach (is_array($paths)? $paths: [$paths] as $path) { |
|
| 91 | + foreach (is_array($paths) ? $paths : [$paths] as $path) { |
|
| 92 | 92 | \Illuminate\Support\Facades\Artisan::call('migrate', ['--path' => $path]); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $paths = $this->migrations(); |
| 99 | 99 | |
| 100 | - foreach (is_array($paths)? $paths: [$paths] as $path) { |
|
| 100 | + foreach (is_array($paths) ? $paths : [$paths] as $path) { |
|
| 101 | 101 | \Illuminate\Support\Facades\Artisan::call('migrate:rollback', ['--path' => $path]); |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -46,7 +46,9 @@ |
||
| 46 | 46 | { |
| 47 | 47 | $templatesDir = static::path() . DIRECTORY_SEPARATOR . 'Templates'; |
| 48 | 48 | |
| 49 | - if (! is_dir($templatesDir)) return; |
|
| 49 | + if (! is_dir($templatesDir)) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $skinDir = $templatesDir . DIRECTORY_SEPARATOR . $skin; |
| 52 | 54 | |
@@ -36,13 +36,13 @@ |
||
| 36 | 36 | return $this; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $this->label = is_array($this->label)? $this->label: [$this->label]; |
|
| 39 | + $this->label = is_array($this->label) ? $this->label : [$this->label]; |
|
| 40 | 40 | |
| 41 | 41 | $this->label = array_map('trans', $this->label); |
| 42 | 42 | |
| 43 | - $this->location = is_array($this->location)? $this->location: [$this->location]; |
|
| 43 | + $this->location = is_array($this->location) ? $this->location : [$this->location]; |
|
| 44 | 44 | |
| 45 | - return array_merge($this->label, $this->location?: []); |
|
| 45 | + return array_merge($this->label, $this->location ?: []); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function label($label) |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | $defaultView = self::module()::view(); |
| 21 | 21 | |
| 22 | - $viewClass = is_a(static::class, ModuleView::class, true)? static::class: $defaultView; |
|
| 22 | + $viewClass = is_a(static::class, ModuleView::class, true) ? static::class : $defaultView; |
|
| 23 | 23 | |
| 24 | 24 | if ($viewClass == $defaultView) $viewClass = null; |
| 25 | 25 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | final public static function moduleLink($module, $method = 'body', $args = []) |
| 40 | 40 | { |
| 41 | - $alias = class_exists($module)? $module::alias(): $module; |
|
| 41 | + $alias = class_exists($module) ? $module::alias() : $module; |
|
| 42 | 42 | |
| 43 | 43 | return url(implode('/', ['view', $alias, $method, self::encodeArgs($args)])); |
| 44 | 44 | } |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
| 53 | 53 | */ |
| 54 | 54 | final public static function decodeArgs($hash) { |
| 55 | - if (! $hash) return []; |
|
| 55 | + if (!$hash) return []; |
|
| 56 | 56 | |
| 57 | 57 | $args = session($hash); |
| 58 | 58 | |
| 59 | 59 | if (is_null($args)) abort(419); |
| 60 | 60 | |
| 61 | - return is_array($args)? $args: [$args]; |
|
| 61 | + return is_array($args) ? $args : [$args]; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | * @return string |
| 69 | 69 | */ |
| 70 | 70 | final public static function encodeArgs($args) { |
| 71 | - $args = is_array($args)? $args: [$args]; |
|
| 71 | + $args = is_array($args) ? $args : [$args]; |
|
| 72 | 72 | |
| 73 | - if (! $args) return; |
|
| 73 | + if (!$args) return; |
|
| 74 | 74 | |
| 75 | 75 | $hash = md5(serialize($args)); |
| 76 | 76 | |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $viewClass = is_a(static::class, ModuleView::class, true)? static::class: $defaultView; |
| 23 | 23 | |
| 24 | - if ($viewClass == $defaultView) $viewClass = null; |
|
| 24 | + if ($viewClass == $defaultView) { |
|
| 25 | + $viewClass = null; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | return url(implode('/', ['view', implode('_', array_filter([self::alias(), $viewClass])), $method, self::encodeArgs($args)])); |
| 27 | 29 | } |
@@ -52,11 +54,15 @@ discard block |
||
| 52 | 54 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
| 53 | 55 | */ |
| 54 | 56 | final public static function decodeArgs($hash) { |
| 55 | - if (! $hash) return []; |
|
| 57 | + if (! $hash) { |
|
| 58 | + return []; |
|
| 59 | + } |
|
| 56 | 60 | |
| 57 | 61 | $args = session($hash); |
| 58 | 62 | |
| 59 | - if (is_null($args)) abort(419); |
|
| 63 | + if (is_null($args)) { |
|
| 64 | + abort(419); |
|
| 65 | + } |
|
| 60 | 66 | |
| 61 | 67 | return is_array($args)? $args: [$args]; |
| 62 | 68 | } |
@@ -70,7 +76,9 @@ discard block |
||
| 70 | 76 | final public static function encodeArgs($args) { |
| 71 | 77 | $args = is_array($args)? $args: [$args]; |
| 72 | 78 | |
| 73 | - if (! $args) return; |
|
| 79 | + if (! $args) { |
|
| 80 | + return; |
|
| 81 | + } |
|
| 74 | 82 | |
| 75 | 83 | $hash = md5(serialize($args)); |
| 76 | 84 | |
@@ -6,16 +6,16 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public function notify($options, $attachTo = null) |
| 8 | 8 | { |
| 9 | - $options = array_merge(['duration'=> 1500], is_array($options)? $options: ['content' => $options]); |
|
| 9 | + $options = array_merge(['duration'=> 1500], is_array($options) ? $options : ['content' => $options]); |
|
| 10 | 10 | |
| 11 | - $attachTo = $attachTo?: $this; |
|
| 11 | + $attachTo = $attachTo ?: $this; |
|
| 12 | 12 | |
| 13 | 13 | return (new \atk4\ui\jsNotify($options, $attachTo)); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function notifyError($options, $attachTo = null) |
| 17 | 17 | { |
| 18 | - $options = array_merge(['color' => 'red'], is_array($options)? $options: ['content' => $options]); |
|
| 18 | + $options = array_merge(['color' => 'red'], is_array($options) ? $options : ['content' => $options]); |
|
| 19 | 19 | |
| 20 | 20 | return $this->notify($options, $attachTo); |
| 21 | 21 | } |
@@ -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() |
@@ -12,11 +12,11 @@ |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | final public static function requireJS($file = 'default.js', $isAsync = false, $isDefer = false) { |
| 15 | - return epesi()->requireJS(self::assetUrl('js/'. $file), $isAsync, $isDefer); |
|
| 15 | + return epesi()->requireJS(self::assetUrl('js/' . $file), $isAsync, $isDefer); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | final public static function requireCSS($file = 'default.css') { |
| 19 | - return epesi()->requireCSS(self::assetUrl('css/'. $file)); |
|
| 19 | + return epesi()->requireCSS(self::assetUrl('css/' . $file)); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |