@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | foreach ($this->module->getOrdered($this->option('direction')) as $module) { |
| 50 | - $this->line('Running for module: <info>' . $module->getName() . '</info>'); |
|
| 50 | + $this->line('Running for module: <info>'.$module->getName().'</info>'); |
|
| 51 | 51 | |
| 52 | 52 | $this->migrate($module); |
| 53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); |
| 64 | 64 | |
| 65 | 65 | if ($this->option('subpath')) { |
| 66 | - $path = $path . "/" . $this->option("subpath"); |
|
| 66 | + $path = $path."/".$this->option("subpath"); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $this->call('migrate', [ |
@@ -126,9 +126,7 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * Creates a new Module instance |
| 128 | 128 | * |
| 129 | - * @param Container $app |
|
| 130 | - * @param string $args |
|
| 131 | - * @param string $path |
|
| 129 | + * @param string[] $args |
|
| 132 | 130 | * @return \Nwidart\Modules\Module |
| 133 | 131 | */ |
| 134 | 132 | abstract protected function createModule(...$args); |
@@ -632,7 +630,7 @@ discard block |
||
| 632 | 630 | /** |
| 633 | 631 | * Get stub path. |
| 634 | 632 | * |
| 635 | - * @return string|null |
|
| 633 | + * @return string|boolean |
|
| 636 | 634 | */ |
| 637 | 635 | public function getStubPath() |
| 638 | 636 | { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $paths = array_merge($paths, $this->config('scan.paths')); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $paths = array_map(function ($path) { |
|
| 119 | + $paths = array_map(function($path) { |
|
| 120 | 120 | return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); |
| 121 | 121 | }, $paths); |
| 122 | 122 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function getCached() |
| 202 | 202 | { |
| 203 | - return $this->cache->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { |
|
| 203 | + return $this->cache->remember($this->config('cache.key'), $this->config('cache.lifetime'), function() { |
|
| 204 | 204 | return $this->toCollection()->toArray(); |
| 205 | 205 | }); |
| 206 | 206 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | { |
| 289 | 289 | $modules = $this->allEnabled(); |
| 290 | 290 | |
| 291 | - uasort($modules, function (Module $a, Module $b) use ($direction) { |
|
| 291 | + uasort($modules, function(Module $a, Module $b) use ($direction) { |
|
| 292 | 292 | if ($a->order == $b->order) { |
| 293 | 293 | return 0; |
| 294 | 294 | } |
@@ -427,9 +427,9 @@ discard block |
||
| 427 | 427 | public function getModulePath($module) |
| 428 | 428 | { |
| 429 | 429 | try { |
| 430 | - return $this->findOrFail($module)->getPath() . '/'; |
|
| 430 | + return $this->findOrFail($module)->getPath().'/'; |
|
| 431 | 431 | } catch (ModuleNotFoundException $e) { |
| 432 | - return $this->getPath() . '/' . Str::studly($module) . '/'; |
|
| 432 | + return $this->getPath().'/'.Str::studly($module).'/'; |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | public function assetPath($module) : string |
| 444 | 444 | { |
| 445 | - return $this->config('paths.assets') . '/' . $module; |
|
| 445 | + return $this->config('paths.assets').'/'.$module; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | public function config(string $key, $default = null) |
| 452 | 452 | { |
| 453 | - return $this->config->get('modules.' . $key, $default); |
|
| 453 | + return $this->config->get('modules.'.$key, $default); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | } |
| 541 | 541 | list($name, $url) = explode(':', $asset); |
| 542 | 542 | |
| 543 | - $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); |
|
| 543 | + $baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); |
|
| 544 | 544 | |
| 545 | - $url = $this->url->asset($baseUrl . "/{$name}/" . $url); |
|
| 545 | + $url = $this->url->asset($baseUrl."/{$name}/".$url); |
|
| 546 | 546 | |
| 547 | 547 | return str_replace(['http://', 'https://'], '//', $url); |
| 548 | 548 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $name = $module->getName(); |
| 98 | 98 | $config = $module->get('migration'); |
| 99 | 99 | if (is_array($config) && array_key_exists('seeds', $config)) { |
| 100 | - foreach ((array)$config['seeds'] as $class) { |
|
| 100 | + foreach ((array) $config['seeds'] as $class) { |
|
| 101 | 101 | if (class_exists($class)) { |
| 102 | 102 | $seeders[] = $class; |
| 103 | 103 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | protected function dbSeed($className) |
| 132 | 132 | { |
| 133 | 133 | if ($option = $this->option('class')) { |
| 134 | - $params['--class'] = Str::finish(substr($className, 0, strrpos($className, '\\')), '\\') . $option; |
|
| 134 | + $params['--class'] = Str::finish(substr($className, 0, strrpos($className, '\\')), '\\').$option; |
|
| 135 | 135 | } else { |
| 136 | 136 | $params = ['--class' => $className]; |
| 137 | 137 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $config = GenerateConfigReader::read('seeder'); |
| 163 | 163 | $seederPath = str_replace('/', '\\', $config->getPath()); |
| 164 | 164 | |
| 165 | - return $namespace . '\\' . $name . '\\' . $config->getNamespace() . '\\' . $name . 'DatabaseSeeder'; |
|
| 165 | + return $namespace.'\\'.$name.'\\'.$config->getNamespace().'\\'.$name.'DatabaseSeeder'; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $foundModules = []; |
| 183 | 183 | foreach ($this->laravel['modules']->config('scan.paths') as $path) { |
| 184 | 184 | $namespace = array_slice(explode('/', $path), -1)[0]; |
| 185 | - $foundModules[] = $namespace . '\\' . $name . '\\' . $seederPath . '\\' . $name . 'DatabaseSeeder'; |
|
| 185 | + $foundModules[] = $namespace.'\\'.$name.'\\'.$seederPath.'\\'.$name.'DatabaseSeeder'; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | return $foundModules; |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function setupStubPath() |
| 33 | 33 | { |
| 34 | - Stub::setBasePath(__DIR__ . '/Commands/stubs'); |
|
| 34 | + Stub::setBasePath(__DIR__.'/Commands/stubs'); |
|
| 35 | 35 | |
| 36 | - $this->app->booted(function ($app) { |
|
| 36 | + $this->app->booted(function($app) { |
|
| 37 | 37 | /** @var RepositoryInterface $moduleRepository */ |
| 38 | 38 | $moduleRepository = $app[RepositoryInterface::class]; |
| 39 | 39 | if ($moduleRepository->config('stubs.enabled') === true) { |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | protected function registerServices() |
| 49 | 49 | { |
| 50 | - $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) { |
|
| 50 | + $this->app->singleton(Contracts\RepositoryInterface::class, function($app) { |
|
| 51 | 51 | $path = $app['config']->get('modules.paths.modules'); |
| 52 | 52 | |
| 53 | 53 | return new Laravel\LaravelFileRepository($app, $path); |
| 54 | 54 | }); |
| 55 | - $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { |
|
| 55 | + $this->app->singleton(Contracts\ActivatorInterface::class, function($app) { |
|
| 56 | 56 | $activator = $app['config']->get('modules.activator'); |
| 57 | - $class = $app['config']->get('modules.activators.' . $activator)['class']; |
|
| 57 | + $class = $app['config']->get('modules.activators.'.$activator)['class']; |
|
| 58 | 58 | |
| 59 | 59 | return new $class($app); |
| 60 | 60 | }); |
@@ -11,144 +11,144 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class FileActivator implements ActivatorInterface |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Laravel cache instance |
|
| 16 | - * |
|
| 17 | - * @var CacheManager |
|
| 18 | - */ |
|
| 19 | - protected $cache; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Laravel Filesystem instance |
|
| 23 | - * |
|
| 24 | - * @var Filesystem |
|
| 25 | - */ |
|
| 26 | - protected $files; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Laravel config instance |
|
| 30 | - * |
|
| 31 | - * @var Config |
|
| 32 | - */ |
|
| 33 | - protected $config; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - protected $cacheKey; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 43 | - protected $cacheLifetime; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Array of modules activation statuses |
|
| 47 | - * |
|
| 48 | - * @var array |
|
| 49 | - */ |
|
| 50 | - protected $modulesStatuses; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * File used to store activation statuses |
|
| 54 | - * |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - protected $statusesFile; |
|
| 58 | - |
|
| 59 | - public function __construct(Container $app) |
|
| 60 | - { |
|
| 61 | - $this->cache = $app['cache']; |
|
| 62 | - $this->files = $app['files']; |
|
| 63 | - $this->config = $app['config']; |
|
| 64 | - $this->statusesFile = $this->config('statuses-file'); |
|
| 65 | - $this->cacheKey = $this->config('cache-key'); |
|
| 66 | - $this->cacheLifetime = $this->config('cache-lifetime'); |
|
| 67 | - $this->modulesStatuses = $this->getModulesStatuses(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Get modules statuses, either from the cache or |
|
| 72 | - * from the json statuses file if the cache is disabled. |
|
| 73 | - * |
|
| 74 | - * @return array |
|
| 75 | - */ |
|
| 76 | - private function getModulesStatuses() |
|
| 77 | - { |
|
| 78 | - if(!$this->config->get('modules.cache.enabled')) return $this->readJson(); |
|
| 14 | + /** |
|
| 15 | + * Laravel cache instance |
|
| 16 | + * |
|
| 17 | + * @var CacheManager |
|
| 18 | + */ |
|
| 19 | + protected $cache; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Laravel Filesystem instance |
|
| 23 | + * |
|
| 24 | + * @var Filesystem |
|
| 25 | + */ |
|
| 26 | + protected $files; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Laravel config instance |
|
| 30 | + * |
|
| 31 | + * @var Config |
|
| 32 | + */ |
|
| 33 | + protected $config; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + protected $cacheKey; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | + protected $cacheLifetime; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Array of modules activation statuses |
|
| 47 | + * |
|
| 48 | + * @var array |
|
| 49 | + */ |
|
| 50 | + protected $modulesStatuses; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * File used to store activation statuses |
|
| 54 | + * |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + protected $statusesFile; |
|
| 58 | + |
|
| 59 | + public function __construct(Container $app) |
|
| 60 | + { |
|
| 61 | + $this->cache = $app['cache']; |
|
| 62 | + $this->files = $app['files']; |
|
| 63 | + $this->config = $app['config']; |
|
| 64 | + $this->statusesFile = $this->config('statuses-file'); |
|
| 65 | + $this->cacheKey = $this->config('cache-key'); |
|
| 66 | + $this->cacheLifetime = $this->config('cache-lifetime'); |
|
| 67 | + $this->modulesStatuses = $this->getModulesStatuses(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Get modules statuses, either from the cache or |
|
| 72 | + * from the json statuses file if the cache is disabled. |
|
| 73 | + * |
|
| 74 | + * @return array |
|
| 75 | + */ |
|
| 76 | + private function getModulesStatuses() |
|
| 77 | + { |
|
| 78 | + if(!$this->config->get('modules.cache.enabled')) return $this->readJson(); |
|
| 79 | 79 | |
| 80 | - return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () { |
|
| 80 | + return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () { |
|
| 81 | 81 | return $this->readJson(); |
| 82 | 82 | }); |
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Flushes the modules activation statuses cache |
|
| 87 | - */ |
|
| 88 | - private function flushCache() |
|
| 89 | - { |
|
| 90 | - $this->cache->forget($this->cacheKey); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Reads a config parameter |
|
| 95 | - * |
|
| 96 | - * @param string $key [description] |
|
| 97 | - * @param $default |
|
| 98 | - * @return mixed |
|
| 99 | - */ |
|
| 100 | - private function config(string $key, $default = null) |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Flushes the modules activation statuses cache |
|
| 87 | + */ |
|
| 88 | + private function flushCache() |
|
| 89 | + { |
|
| 90 | + $this->cache->forget($this->cacheKey); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Reads a config parameter |
|
| 95 | + * |
|
| 96 | + * @param string $key [description] |
|
| 97 | + * @param $default |
|
| 98 | + * @return mixed |
|
| 99 | + */ |
|
| 100 | + private function config(string $key, $default = null) |
|
| 101 | 101 | { |
| 102 | 102 | return $this->config->get('modules.activators.file.' . $key, $default); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Reads the json file that contains the activation statuses. |
|
| 107 | - * |
|
| 108 | - * @return array |
|
| 109 | - */ |
|
| 110 | - private function readJson() |
|
| 111 | - { |
|
| 112 | - if(!$this->files->exists($this->statusesFile)) return []; |
|
| 113 | - return json_decode($this->files->get($this->statusesFile), true); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Writes the activation statuses in a file, as json |
|
| 118 | - */ |
|
| 119 | - private function writeJson() |
|
| 120 | - { |
|
| 121 | - $this->files->put($this->statusesFile, json_encode($this->modulesStatuses, JSON_PRETTY_PRINT)); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Get the path of the file where statuses are stored |
|
| 126 | - * |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function getStatusesFilePath() |
|
| 130 | - { |
|
| 131 | - return $this->statusesFile; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @inheritDoc |
|
| 136 | - */ |
|
| 137 | - public function reset() |
|
| 138 | - { |
|
| 139 | - if($this->files->exists($this->statusesFile)){ |
|
| 140 | - $this->files->delete($this->statusesFile); |
|
| 141 | - } |
|
| 142 | - $this->modulesStatuses = []; |
|
| 143 | - $this->flushCache(); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 105 | + /** |
|
| 106 | + * Reads the json file that contains the activation statuses. |
|
| 107 | + * |
|
| 108 | + * @return array |
|
| 109 | + */ |
|
| 110 | + private function readJson() |
|
| 111 | + { |
|
| 112 | + if(!$this->files->exists($this->statusesFile)) return []; |
|
| 113 | + return json_decode($this->files->get($this->statusesFile), true); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Writes the activation statuses in a file, as json |
|
| 118 | + */ |
|
| 119 | + private function writeJson() |
|
| 120 | + { |
|
| 121 | + $this->files->put($this->statusesFile, json_encode($this->modulesStatuses, JSON_PRETTY_PRINT)); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Get the path of the file where statuses are stored |
|
| 126 | + * |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function getStatusesFilePath() |
|
| 130 | + { |
|
| 131 | + return $this->statusesFile; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @inheritDoc |
|
| 136 | + */ |
|
| 137 | + public function reset() |
|
| 138 | + { |
|
| 139 | + if($this->files->exists($this->statusesFile)){ |
|
| 140 | + $this->files->delete($this->statusesFile); |
|
| 141 | + } |
|
| 142 | + $this->modulesStatuses = []; |
|
| 143 | + $this->flushCache(); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | 147 | * @inheritDoc |
| 148 | 148 | */ |
| 149 | 149 | public function enable(Module $module) |
| 150 | 150 | { |
| 151 | - $this->setActiveByName($module->getName(), true); |
|
| 151 | + $this->setActiveByName($module->getName(), true); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function disable(Module $module) |
| 158 | 158 | { |
| 159 | - $this->setActiveByName($module->getName(), false); |
|
| 159 | + $this->setActiveByName($module->getName(), false); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function isStatus(Module $module, bool $status): bool |
| 166 | 166 | { |
| 167 | - if(!isset($this->modulesStatuses[$module->getName()])){ |
|
| 168 | - return $status === false; |
|
| 169 | - } |
|
| 170 | - return $this->modulesStatuses[$module->getName()] === $status; |
|
| 167 | + if(!isset($this->modulesStatuses[$module->getName()])){ |
|
| 168 | + return $status === false; |
|
| 169 | + } |
|
| 170 | + return $this->modulesStatuses[$module->getName()] === $status; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function setActive(Module $module, bool $active) |
| 177 | 177 | { |
| 178 | - $this->setActiveByName($module->getName(), $active); |
|
| 178 | + $this->setActiveByName($module->getName(), $active); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function setActiveByName(string $name, bool $status) |
| 185 | 185 | { |
| 186 | - $this->modulesStatuses[$name] = $status; |
|
| 187 | - $this->writeJson(); |
|
| 188 | - $this->flushCache(); |
|
| 186 | + $this->modulesStatuses[$name] = $status; |
|
| 187 | + $this->writeJson(); |
|
| 188 | + $this->flushCache(); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function delete(Module $module) |
| 195 | 195 | { |
| 196 | - if(!isset($this->modulesStatuses[$module->getName()])) return; |
|
| 197 | - unset($this->modulesStatuses[$module->getName()]); |
|
| 198 | - $this->writeJson(); |
|
| 199 | - $this->flushCache(); |
|
| 196 | + if(!isset($this->modulesStatuses[$module->getName()])) return; |
|
| 197 | + unset($this->modulesStatuses[$module->getName()]); |
|
| 198 | + $this->writeJson(); |
|
| 199 | + $this->flushCache(); |
|
| 200 | 200 | } |
| 201 | 201 | } |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | private function getModulesStatuses() |
| 77 | 77 | { |
| 78 | - if(!$this->config->get('modules.cache.enabled')) return $this->readJson(); |
|
| 78 | + if (!$this->config->get('modules.cache.enabled')) return $this->readJson(); |
|
| 79 | 79 | |
| 80 | - return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () { |
|
| 80 | + return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function() { |
|
| 81 | 81 | return $this->readJson(); |
| 82 | 82 | }); |
| 83 | 83 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | private function config(string $key, $default = null) |
| 101 | 101 | { |
| 102 | - return $this->config->get('modules.activators.file.' . $key, $default); |
|
| 102 | + return $this->config->get('modules.activators.file.'.$key, $default); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | private function readJson() |
| 111 | 111 | { |
| 112 | - if(!$this->files->exists($this->statusesFile)) return []; |
|
| 112 | + if (!$this->files->exists($this->statusesFile)) return []; |
|
| 113 | 113 | return json_decode($this->files->get($this->statusesFile), true); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function reset() |
| 138 | 138 | { |
| 139 | - if($this->files->exists($this->statusesFile)){ |
|
| 139 | + if ($this->files->exists($this->statusesFile)) { |
|
| 140 | 140 | $this->files->delete($this->statusesFile); |
| 141 | 141 | } |
| 142 | 142 | $this->modulesStatuses = []; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function isStatus(Module $module, bool $status): bool |
| 166 | 166 | { |
| 167 | - if(!isset($this->modulesStatuses[$module->getName()])){ |
|
| 167 | + if (!isset($this->modulesStatuses[$module->getName()])) { |
|
| 168 | 168 | return $status === false; |
| 169 | 169 | } |
| 170 | 170 | return $this->modulesStatuses[$module->getName()] === $status; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function delete(Module $module) |
| 195 | 195 | { |
| 196 | - if(!isset($this->modulesStatuses[$module->getName()])) return; |
|
| 196 | + if (!isset($this->modulesStatuses[$module->getName()])) return; |
|
| 197 | 197 | unset($this->modulesStatuses[$module->getName()]); |
| 198 | 198 | $this->writeJson(); |
| 199 | 199 | $this->flushCache(); |
@@ -75,7 +75,9 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | private function getModulesStatuses() |
| 77 | 77 | { |
| 78 | - if(!$this->config->get('modules.cache.enabled')) return $this->readJson(); |
|
| 78 | + if(!$this->config->get('modules.cache.enabled')) { |
|
| 79 | + return $this->readJson(); |
|
| 80 | + } |
|
| 79 | 81 | |
| 80 | 82 | return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () { |
| 81 | 83 | return $this->readJson(); |
@@ -109,7 +111,9 @@ discard block |
||
| 109 | 111 | */ |
| 110 | 112 | private function readJson() |
| 111 | 113 | { |
| 112 | - if(!$this->files->exists($this->statusesFile)) return []; |
|
| 114 | + if(!$this->files->exists($this->statusesFile)) { |
|
| 115 | + return []; |
|
| 116 | + } |
|
| 113 | 117 | return json_decode($this->files->get($this->statusesFile), true); |
| 114 | 118 | } |
| 115 | 119 | |
@@ -193,7 +197,9 @@ discard block |
||
| 193 | 197 | */ |
| 194 | 198 | public function delete(Module $module) |
| 195 | 199 | { |
| 196 | - if(!isset($this->modulesStatuses[$module->getName()])) return; |
|
| 200 | + if(!isset($this->modulesStatuses[$module->getName()])) { |
|
| 201 | + return; |
|
| 202 | + } |
|
| 197 | 203 | unset($this->modulesStatuses[$module->getName()]); |
| 198 | 204 | $this->writeJson(); |
| 199 | 205 | $this->flushCache(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function setupStubPath() |
| 33 | 33 | { |
| 34 | - Stub::setBasePath(__DIR__ . '/Commands/stubs'); |
|
| 34 | + Stub::setBasePath(__DIR__.'/Commands/stubs'); |
|
| 35 | 35 | |
| 36 | 36 | if (app('modules')->config('stubs.enabled') === true) { |
| 37 | 37 | Stub::setBasePath(app('modules')->config('stubs.path')); |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | protected function registerServices() |
| 45 | 45 | { |
| 46 | - $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) { |
|
| 46 | + $this->app->singleton(Contracts\RepositoryInterface::class, function($app) { |
|
| 47 | 47 | $path = $app['config']->get('modules.paths.modules'); |
| 48 | 48 | |
| 49 | 49 | return new Lumen\LumenFileRepository($app, $path); |
| 50 | 50 | }); |
| 51 | - $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { |
|
| 51 | + $this->app->singleton(Contracts\ActivatorInterface::class, function($app) { |
|
| 52 | 52 | $activator = $app['config']->get('modules.activator'); |
| 53 | - $class = $app['config']->get('modules.activators.' . $activator)['class']; |
|
| 53 | + $class = $app['config']->get('modules.activators.'.$activator)['class']; |
|
| 54 | 54 | |
| 55 | 55 | return new $class($app); |
| 56 | 56 | }); |