@@ -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 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | public function index() |
| 14 | 14 | { |
| 15 | - return SystemCore::isInstalled()? redirect('home'): redirect('install'); |
|
| 15 | + return SystemCore::isInstalled() ? redirect('home') : redirect('install'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function install(Epesi $epesi) |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function home() |
| 38 | 38 | { |
| 39 | - return redirect(SystemCore::isInstalled()? \Epesi\Core\HomePage\HomePageSettings::getUserHomePagePath(): 'install'); |
|
| 39 | + return redirect(SystemCore::isInstalled() ? \Epesi\Core\HomePage\HomePageSettings::getUserHomePagePath() : 'install'); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function logo() |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if (! $view) abort(404); |
|
| 67 | + if (!$view) abort(404); |
|
| 68 | 68 | |
| 69 | 69 | $epesi->add($view)->displayModuleContent($method, $args); |
| 70 | 70 | |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | // make sure the installation information is fresh |
| 21 | 21 | ModuleManager::clearCache(); |
| 22 | 22 | |
| 23 | - if (SystemCore::isInstalled()) return redirect('home'); |
|
| 23 | + if (SystemCore::isInstalled()) { |
|
| 24 | + return redirect('home'); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | $epesi->title = __(':epesi > Installation', ['epesi' => config('epesi.app.title')]); |
| 26 | 28 | |
@@ -64,7 +66,9 @@ discard block |
||
| 64 | 66 | } |
| 65 | 67 | } |
| 66 | 68 | |
| 67 | - if (! $view) abort(404); |
|
| 69 | + if (! $view) { |
|
| 70 | + abort(404); |
|
| 71 | + } |
|
| 68 | 72 | |
| 69 | 73 | $epesi->add($view)->displayModuleContent($method, $args); |
| 70 | 74 | |
@@ -11,66 +11,66 @@ |
||
| 11 | 11 | |
| 12 | 12 | class SystemController extends Controller |
| 13 | 13 | { |
| 14 | - public function index() |
|
| 15 | - { |
|
| 16 | - return SystemCore::isInstalled()? redirect('home'): redirect('install'); |
|
| 17 | - } |
|
| 14 | + public function index() |
|
| 15 | + { |
|
| 16 | + return SystemCore::isInstalled()? redirect('home'): redirect('install'); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function install(Epesi $epesi) |
|
| 20 | - { |
|
| 21 | - // make sure the installation information is fresh |
|
| 22 | - ModuleManager::clearCache(); |
|
| 19 | + public function install(Epesi $epesi) |
|
| 20 | + { |
|
| 21 | + // make sure the installation information is fresh |
|
| 22 | + ModuleManager::clearCache(); |
|
| 23 | 23 | |
| 24 | - if (SystemCore::isInstalled()) return redirect('home'); |
|
| 24 | + if (SystemCore::isInstalled()) return redirect('home'); |
|
| 25 | 25 | |
| 26 | - $epesi->title = __(':epesi > Installation', ['epesi' => config('epesi.app.title')]); |
|
| 26 | + $epesi->title = __(':epesi > Installation', ['epesi' => config('epesi.app.title')]); |
|
| 27 | 27 | |
| 28 | - $epesi->initLayout('Centered'); |
|
| 28 | + $epesi->initLayout('Centered'); |
|
| 29 | 29 | |
| 30 | - $epesi->layout->set('logo', url('logo')); |
|
| 31 | - $epesi->layout->template->setHTML('copyright', config('epesi.app.copyright')); |
|
| 30 | + $epesi->layout->set('logo', url('logo')); |
|
| 31 | + $epesi->layout->template->setHTML('copyright', config('epesi.app.copyright')); |
|
| 32 | 32 | |
| 33 | - $epesi->add(new \Epesi\Core\System\SystemInstallWizard()); |
|
| 33 | + $epesi->add(new \Epesi\Core\System\SystemInstallWizard()); |
|
| 34 | 34 | |
| 35 | - return $epesi->response(); |
|
| 36 | - } |
|
| 35 | + return $epesi->response(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function home() |
|
| 39 | - { |
|
| 40 | - return redirect(SystemCore::isInstalled()? \Epesi\Core\HomePage\HomePageSettings::getUserHomePagePath(): 'install'); |
|
| 41 | - } |
|
| 38 | + public function home() |
|
| 39 | + { |
|
| 40 | + return redirect(SystemCore::isInstalled()? \Epesi\Core\HomePage\HomePageSettings::getUserHomePagePath(): 'install'); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function logo() |
|
| 44 | - { |
|
| 45 | - $logoFile = \Epesi\Core\System\Logo\LogoSettings::getLogoFile(); |
|
| 43 | + public function logo() |
|
| 44 | + { |
|
| 45 | + $logoFile = \Epesi\Core\System\Logo\LogoSettings::getLogoFile(); |
|
| 46 | 46 | |
| 47 | - return response(File::get($logoFile), 200, ['Content-type' => File::mimeType($logoFile)])->setMaxAge(604800)->setPublic(); |
|
| 48 | - } |
|
| 47 | + return response(File::get($logoFile), 200, ['Content-type' => File::mimeType($logoFile)])->setMaxAge(604800)->setPublic(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function view(Epesi $epesi, $module, $method = 'body', $args = []) |
|
| 51 | - { |
|
| 52 | - $epesi->initLayout(new LayoutView()); |
|
| 50 | + public function view(Epesi $epesi, $module, $method = 'body', $args = []) |
|
| 51 | + { |
|
| 52 | + $epesi->initLayout(new LayoutView()); |
|
| 53 | 53 | |
| 54 | - $alias = explode(':', $module); |
|
| 54 | + $alias = explode(':', $module); |
|
| 55 | 55 | |
| 56 | - $moduleAlias = $alias[0]; |
|
| 57 | - $viewAlias = $alias[1]?? null; |
|
| 56 | + $moduleAlias = $alias[0]; |
|
| 57 | + $viewAlias = $alias[1]?? null; |
|
| 58 | 58 | |
| 59 | - $view = null; |
|
| 60 | - if ($module = ModuleManager::getClass($moduleAlias, true)) { |
|
| 61 | - $viewClass = $module::view($viewAlias); |
|
| 59 | + $view = null; |
|
| 60 | + if ($module = ModuleManager::getClass($moduleAlias, true)) { |
|
| 61 | + $viewClass = $module::view($viewAlias); |
|
| 62 | 62 | |
| 63 | - if (class_exists($viewClass)) { |
|
| 64 | - $view = new $viewClass(); |
|
| 65 | - } |
|
| 66 | - } |
|
| 63 | + if (class_exists($viewClass)) { |
|
| 64 | + $view = new $viewClass(); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - if (! $view) abort(404); |
|
| 68 | + if (! $view) abort(404); |
|
| 69 | 69 | |
| 70 | - $epesi->add($view)->displayModuleContent($method, $args); |
|
| 70 | + $epesi->add($view)->displayModuleContent($method, $args); |
|
| 71 | 71 | |
| 72 | - $epesi->setLocation($view->location()); |
|
| 72 | + $epesi->setLocation($view->location()); |
|
| 73 | 73 | |
| 74 | - return $epesi->response(); |
|
| 75 | - } |
|
| 74 | + return $epesi->response(); |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | private static $variables; |
| 18 | 18 | |
| 19 | 19 | private static function cache() { |
| 20 | - if(isset(self::$variables)) return; |
|
| 20 | + if (isset(self::$variables)) return; |
|
| 21 | 21 | |
| 22 | 22 | self::$variables = self::pluck('value', 'name'); |
| 23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public static function get($name, $default = null) { |
| 26 | 26 | self::cache(); |
| 27 | 27 | |
| 28 | - if (! self::$variables->has($name)) return $default; |
|
| 28 | + if (!self::$variables->has($name)) return $default; |
|
| 29 | 29 | |
| 30 | 30 | return self::$variables->get($name, $default)?? $default; |
| 31 | 31 | } |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | return self::updateOrCreate(compact('name'), compact('value')); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public static function forget($name, $throwError=true) { |
|
| 47 | + public static function forget($name, $throwError = true) { |
|
| 48 | 48 | self::cache(); |
| 49 | 49 | |
| 50 | - if (! self::$variables->has($name) && $throwError) { |
|
| 50 | + if (!self::$variables->has($name) && $throwError) { |
|
| 51 | 51 | throw new \Exception('No such variable in database: ' . $name); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | private static $variables; |
| 18 | 18 | |
| 19 | 19 | private static function cache() { |
| 20 | - if(isset(self::$variables)) return; |
|
| 20 | + if(isset(self::$variables)) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | |
| 22 | 24 | self::$variables = self::pluck('value', 'name'); |
| 23 | 25 | } |
@@ -25,7 +27,9 @@ discard block |
||
| 25 | 27 | public static function get($name, $default = null) { |
| 26 | 28 | self::cache(); |
| 27 | 29 | |
| 28 | - if (! self::$variables->has($name)) return $default; |
|
| 30 | + if (! self::$variables->has($name)) { |
|
| 31 | + return $default; |
|
| 32 | + } |
|
| 29 | 33 | |
| 30 | 34 | return self::$variables->get($name, $default)?? $default; |
| 31 | 35 | } |
@@ -6,37 +6,37 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateCoreTables extends Migration |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function up() |
|
| 15 | - { |
|
| 16 | - $this->down(); |
|
| 9 | + /** |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function up() |
|
| 15 | + { |
|
| 16 | + $this->down(); |
|
| 17 | 17 | |
| 18 | - Schema::create('variables', function (Blueprint $table) { |
|
| 19 | - $table->string('name', 128)->primary(); |
|
| 20 | - $table->text('value')->nullable(); |
|
| 21 | - }); |
|
| 18 | + Schema::create('variables', function (Blueprint $table) { |
|
| 19 | + $table->string('name', 128)->primary(); |
|
| 20 | + $table->text('value')->nullable(); |
|
| 21 | + }); |
|
| 22 | 22 | |
| 23 | - Schema::create('modules', function (Blueprint $table) { |
|
| 24 | - $table->string('class', 512); |
|
| 25 | - $table->string('alias', 128)->unique(); |
|
| 26 | - $table->smallInteger('priority')->default(0); |
|
| 27 | - $table->smallInteger('state')->default(1); |
|
| 28 | - }); |
|
| 29 | - } |
|
| 23 | + Schema::create('modules', function (Blueprint $table) { |
|
| 24 | + $table->string('class', 512); |
|
| 25 | + $table->string('alias', 128)->unique(); |
|
| 26 | + $table->smallInteger('priority')->default(0); |
|
| 27 | + $table->smallInteger('state')->default(1); |
|
| 28 | + }); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Reverse the migrations. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public function down() |
|
| 37 | - { |
|
| 38 | - Schema::dropIfExists('variables'); |
|
| 31 | + /** |
|
| 32 | + * Reverse the migrations. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public function down() |
|
| 37 | + { |
|
| 38 | + Schema::dropIfExists('variables'); |
|
| 39 | 39 | |
| 40 | - Schema::dropIfExists('modules'); |
|
| 41 | - } |
|
| 40 | + Schema::dropIfExists('modules'); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -15,12 +15,12 @@ |
||
| 15 | 15 | { |
| 16 | 16 | $this->down(); |
| 17 | 17 | |
| 18 | - Schema::create('variables', function (Blueprint $table) { |
|
| 18 | + Schema::create('variables', function(Blueprint $table) { |
|
| 19 | 19 | $table->string('name', 128)->primary(); |
| 20 | 20 | $table->text('value')->nullable(); |
| 21 | 21 | }); |
| 22 | 22 | |
| 23 | - Schema::create('modules', function (Blueprint $table) { |
|
| 23 | + Schema::create('modules', function(Blueprint $table) { |
|
| 24 | 24 | $table->string('class', 512); |
| 25 | 25 | $table->string('alias', 128)->unique(); |
| 26 | 26 | $table->smallInteger('priority')->default(0); |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $modules = ModuleManager::getAll(); |
| 30 | 30 | |
| 31 | - return $modules->filter(function ($subModuleClass) use ($modules) { |
|
| 32 | - return ! $modules->map(function($moduleClass){ |
|
| 31 | + return $modules->filter(function($subModuleClass) use ($modules) { |
|
| 32 | + return !$modules->map(function($moduleClass) { |
|
| 33 | 33 | return $moduleClass::namespace(); |
| 34 | 34 | })->contains($subModuleClass::parentNamespace()); |
| 35 | 35 | })->sort(); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $section->add($label, 'title')->setStyle('float', 'right'); |
| 62 | 62 | |
| 63 | - $submodules = ModuleManager::getAll()->filter(function ($subModuleClass) use ($moduleClass) { |
|
| 63 | + $submodules = ModuleManager::getAll()->filter(function($subModuleClass) use ($moduleClass) { |
|
| 64 | 64 | return $subModuleClass::isSubModuleOf($moduleClass); |
| 65 | 65 | }); |
| 66 | 66 | |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function formatModuleInfo($moduleClass) |
| 74 | 74 | { |
| 75 | - $moduleInfo = (array) ($moduleClass::info()?: __(' No details provided by author')); |
|
| 75 | + $moduleInfo = (array) ($moduleClass::info() ?: __(' No details provided by author')); |
|
| 76 | 76 | |
| 77 | 77 | $ret = []; |
| 78 | 78 | foreach ($moduleInfo as $label => $text) { |
| 79 | - $ret[] = (is_string($label)? "<strong>$label</strong>: ": '') . $text; |
|
| 79 | + $ret[] = (is_string($label) ? "<strong>$label</strong>: " : '') . $text; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return implode('<br>', $ret); |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $form = $view->add(new Form()); |
| 111 | 111 | foreach ($recommended as $childModule) { |
| 112 | - if (! ModuleManager::isAvailable($childModule)) continue; |
|
| 112 | + if (!ModuleManager::isAvailable($childModule)) continue; |
|
| 113 | 113 | |
| 114 | 114 | $form->addField($childModule::alias(), ['CheckBox', 'caption' => $childModule::label()]); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $form->onSubmit(function ($form) use ($moduleClass) { |
|
| 117 | + $form->onSubmit(function($form) use ($moduleClass) { |
|
| 118 | 118 | ob_start(); |
| 119 | 119 | ModuleManager::install($moduleClass, array_keys($form->getValues(), true)); |
| 120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $view->add(['Button', __('Install'), 'primary'])->on('click', [ |
| 126 | - isset($form)? $form->submit(): $installCallback |
|
| 126 | + isset($form) ? $form->submit() : $installCallback |
|
| 127 | 127 | ]); |
| 128 | 128 | }); |
| 129 | 129 | |
@@ -51,8 +51,7 @@ discard block |
||
| 51 | 51 | $this->addUninstallButton($section, $moduleClass); |
| 52 | 52 | |
| 53 | 53 | // $this->addReinstallButton($section, $moduleClass); |
| 54 | - } |
|
| 55 | - else { |
|
| 54 | + } else { |
|
| 56 | 55 | $label = ['Label', __('Available'), 'yellow']; |
| 57 | 56 | |
| 58 | 57 | $this->addInstallButton($section, $moduleClass); |
@@ -64,7 +63,9 @@ discard block |
||
| 64 | 63 | return $subModuleClass::isSubModuleOf($moduleClass); |
| 65 | 64 | }); |
| 66 | 65 | |
| 67 | - if ($submodules->isEmpty()) continue; |
|
| 66 | + if ($submodules->isEmpty()) { |
|
| 67 | + continue; |
|
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | $this->addAccordion($section, $submodules); |
| 70 | 71 | } |
@@ -109,7 +110,9 @@ discard block |
||
| 109 | 110 | |
| 110 | 111 | $form = $view->add(new Form()); |
| 111 | 112 | foreach ($recommended as $childModule) { |
| 112 | - if (! ModuleManager::isAvailable($childModule)) continue; |
|
| 113 | + if (! ModuleManager::isAvailable($childModule)) { |
|
| 114 | + continue; |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | $form->addField($childModule::alias(), ['CheckBox', 'caption' => $childModule::label()]); |
| 115 | 118 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $defaultView = self::module()::view(); |
| 22 | 22 | |
| 23 | - $viewClass = is_a(static::class, ModuleView::class, true)? static::class: $defaultView; |
|
| 23 | + $viewClass = is_a(static::class, ModuleView::class, true) ? static::class : $defaultView; |
|
| 24 | 24 | |
| 25 | 25 | $viewAlias = null; |
| 26 | 26 | if ($viewClass !== $defaultView) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | final public static function moduleLink($module, $method = 'body', $args = []) |
| 46 | 46 | { |
| 47 | - $alias = class_exists($module)? $module::alias(): $module; |
|
| 47 | + $alias = class_exists($module) ? $module::alias() : $module; |
|
| 48 | 48 | |
| 49 | 49 | return url(implode('/', ['view', $alias, $method, self::encodeArgs($args)])); |
| 50 | 50 | } |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
| 59 | 59 | */ |
| 60 | 60 | final public static function decodeArgs($hash) { |
| 61 | - if (! $hash) return []; |
|
| 61 | + if (!$hash) return []; |
|
| 62 | 62 | |
| 63 | 63 | $args = session($hash); |
| 64 | 64 | |
| 65 | 65 | if (is_null($args)) abort(419); |
| 66 | 66 | |
| 67 | - return is_array($args)? $args: [$args]; |
|
| 67 | + return is_array($args) ? $args : [$args]; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | 76 | final public static function encodeArgs($args) { |
| 77 | - $args = is_array($args)? $args: [$args]; |
|
| 77 | + $args = is_array($args) ? $args : [$args]; |
|
| 78 | 78 | |
| 79 | - if (! $args) return; |
|
| 79 | + if (!$args) return; |
|
| 80 | 80 | |
| 81 | 81 | $hash = md5(serialize($args)); |
| 82 | 82 | |
@@ -58,11 +58,15 @@ discard block |
||
| 58 | 58 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
| 59 | 59 | */ |
| 60 | 60 | final public static function decodeArgs($hash) { |
| 61 | - if (! $hash) return []; |
|
| 61 | + if (! $hash) { |
|
| 62 | + return []; |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | $args = session($hash); |
| 64 | 66 | |
| 65 | - if (is_null($args)) abort(419); |
|
| 67 | + if (is_null($args)) { |
|
| 68 | + abort(419); |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | return is_array($args)? $args: [$args]; |
| 68 | 72 | } |
@@ -76,7 +80,9 @@ discard block |
||
| 76 | 80 | final public static function encodeArgs($args) { |
| 77 | 81 | $args = is_array($args)? $args: [$args]; |
| 78 | 82 | |
| 79 | - if (! $args) return; |
|
| 83 | + if (! $args) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 80 | 86 | |
| 81 | 87 | $hash = md5(serialize($args)); |
| 82 | 88 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public static function isInstalled($classOrAlias) |
| 22 | 22 | { |
| 23 | - return self::getClass($classOrAlias, true)? 1: 0; |
|
| 23 | + return self::getClass($classOrAlias, true) ? 1 : 0; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function isAvailable($classOrAlias) |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @return string; |
| 36 | 36 | */ |
| 37 | 37 | public static function getClass($classOrAlias, $installedOnly = false) { |
| 38 | - $modules = $installedOnly? self::getInstalled(): self::getAll(); |
|
| 38 | + $modules = $installedOnly ? self::getInstalled() : self::getAll(); |
|
| 39 | 39 | |
| 40 | 40 | if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
| 41 | 41 | |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public static function getAll() |
| 69 | 69 | { |
| 70 | - return self::getCached('epesi-modules-available', function () { |
|
| 70 | + return self::getCached('epesi-modules-available', function() { |
|
| 71 | 71 | $modules = collect(); |
| 72 | - foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules()?: []) as $namespace => $path) { |
|
| 72 | + foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules() ?: []) as $namespace => $path) { |
|
| 73 | 73 | foreach (self::discoverModuleClasses($namespace, $path) as $moduleClass) { |
| 74 | 74 | $modules->add(['alias' => $moduleClass::alias(), 'class' => $moduleClass]); |
| 75 | 75 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | protected static function discoverModuleClasses($namespace, $basePath) |
| 83 | 83 | { |
| 84 | 84 | $ret = collect(); |
| 85 | - foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
| 85 | + foreach (glob($basePath . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $path) { |
|
| 86 | 86 | $moduleNamespace = trim($namespace, '\\'); |
| 87 | 87 | |
| 88 | 88 | $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $names = array_slice(explode('\\', $moduleNamespace), -1); |
| 93 | 93 | |
| 94 | - if (! $name = $names? reset($names): '') continue; |
|
| 94 | + if (!$name = $names ? reset($names) : '') continue; |
|
| 95 | 95 | |
| 96 | 96 | $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
| 97 | 97 | |
| 98 | - if (! is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 98 | + if (!is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 99 | 99 | |
| 100 | 100 | $ret->add($moduleClass); |
| 101 | 101 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected static function getCached($key, \Closure $default) |
| 114 | 114 | { |
| 115 | - if (! Cache::has($key)) { |
|
| 115 | + if (!Cache::has($key)) { |
|
| 116 | 116 | Cache::forever($key, $default()); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public static function collect($method, $args = []) |
| 152 | 152 | { |
| 153 | - $args = is_array($args)? $args: [$args]; |
|
| 153 | + $args = is_array($args) ? $args : [$args]; |
|
| 154 | 154 | |
| 155 | 155 | $installedModules = self::getInstalled(); |
| 156 | 156 | |
| 157 | 157 | // if epesi is not installed fake having the system module to enable its functionality |
| 158 | - if (! $installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 158 | + if (!$installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 159 | 159 | $installedModules = collect([ |
| 160 | 160 | 'system' => \Epesi\Core\System\SystemCore::class |
| 161 | 161 | ]); |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $ret = []; |
| 165 | 165 | foreach ($installedModules as $module) { |
| 166 | - if (! $list = $module::$method(...$args)) continue; |
|
| 166 | + if (!$list = $module::$method(...$args)) continue; |
|
| 167 | 167 | |
| 168 | - $ret = array_merge($ret, is_array($list)? $list: [$list]); |
|
| 168 | + $ret = array_merge($ret, is_array($list) ? $list : [$list]); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $ret; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | return true; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 187 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 188 | 188 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | ]); |
| 215 | 215 | |
| 216 | 216 | if ($installRecommended) { |
| 217 | - $installRecommended = is_array($installRecommended)? $installRecommended: $module->recommended(); |
|
| 217 | + $installRecommended = is_array($installRecommended) ? $installRecommended : $module->recommended(); |
|
| 218 | 218 | |
| 219 | 219 | foreach ($installRecommended as $recommendedModule) { |
| 220 | 220 | try { |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | $parentModule = array_shift($unsatisfiedDependencies); |
| 248 | 248 | |
| 249 | 249 | if (self::$processing[$parentModule]?? false) { |
| 250 | - throw new Exception('Cross dependency: '. $parentModule); |
|
| 250 | + throw new Exception('Cross dependency: ' . $parentModule); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if (! self::isAvailable($parentModule)) { |
|
| 253 | + if (!self::isAvailable($parentModule)) { |
|
| 254 | 254 | throw new Exception('Module not found: "' . $parentModule . '"'); |
| 255 | 255 | } |
| 256 | 256 | |
@@ -303,13 +303,13 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | public static function uninstall($classOrAlias) |
| 305 | 305 | { |
| 306 | - if (! self::isInstalled($classOrAlias)) { |
|
| 306 | + if (!self::isInstalled($classOrAlias)) { |
|
| 307 | 307 | print ('Module "' . $classOrAlias . '" is not installed!'); |
| 308 | 308 | |
| 309 | 309 | return true; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 312 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 313 | 313 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -37,7 +37,9 @@ discard block |
||
| 37 | 37 | public static function getClass($classOrAlias, $installedOnly = false) { |
| 38 | 38 | $modules = $installedOnly? self::getInstalled(): self::getAll(); |
| 39 | 39 | |
| 40 | - if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
|
| 40 | + if (collect($modules)->contains($classOrAlias)) { |
|
| 41 | + return $classOrAlias; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | return $modules[$classOrAlias]?? null; |
| 43 | 45 | } |
@@ -91,11 +93,15 @@ discard block |
||
| 91 | 93 | |
| 92 | 94 | $names = array_slice(explode('\\', $moduleNamespace), -1); |
| 93 | 95 | |
| 94 | - if (! $name = $names? reset($names): '') continue; |
|
| 96 | + if (! $name = $names? reset($names): '') { |
|
| 97 | + continue; |
|
| 98 | + } |
|
| 95 | 99 | |
| 96 | 100 | $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
| 97 | 101 | |
| 98 | - if (! is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 102 | + if (! is_a($moduleClass, ModuleCore::class, true)) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 99 | 105 | |
| 100 | 106 | $ret->add($moduleClass); |
| 101 | 107 | } |
@@ -163,7 +169,9 @@ discard block |
||
| 163 | 169 | |
| 164 | 170 | $ret = []; |
| 165 | 171 | foreach ($installedModules as $module) { |
| 166 | - if (! $list = $module::$method(...$args)) continue; |
|
| 172 | + if (! $list = $module::$method(...$args)) { |
|
| 173 | + continue; |
|
| 174 | + } |
|
| 167 | 175 | |
| 168 | 176 | $ret = array_merge($ret, is_array($list)? $list: [$list]); |
| 169 | 177 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | //TODO: set the skin from admin / user selection |
| 34 | 34 | $this->skin = config('epesi.app.skin', $this->skin); |
| 35 | 35 | |
| 36 | - $this->template_dir = array_merge(ModuleManager::collect('templates', $this->skin), $this->template_dir?: []); |
|
| 36 | + $this->template_dir = array_merge(ModuleManager::collect('templates', $this->skin), $this->template_dir ?: []); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | final public static function module() |
@@ -87,35 +87,35 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | // jQuery |
| 89 | 89 | $urlJs = $this->cdn['jquery']?? $localJs; |
| 90 | - $this->requireJS($urlJs.'/jquery.min.js'); |
|
| 90 | + $this->requireJS($urlJs . '/jquery.min.js'); |
|
| 91 | 91 | |
| 92 | 92 | // Semantic UI |
| 93 | 93 | $urlJs = $this->cdn['semantic-ui']?? $localJs; |
| 94 | 94 | $urlCss = $this->cdn['semantic-ui']?? $localCss; |
| 95 | - $this->requireJS($urlJs.'/semantic.min.js'); |
|
| 96 | - $this->requireCSS($urlCss.'/semantic.min.css'); |
|
| 95 | + $this->requireJS($urlJs . '/semantic.min.js'); |
|
| 96 | + $this->requireCSS($urlCss . '/semantic.min.css'); |
|
| 97 | 97 | |
| 98 | 98 | // Serialize Object |
| 99 | 99 | $urlJs = $this->cdn['serialize-object']?? $localJs; |
| 100 | - $this->requireJS($urlJs.'/jquery.serialize-object.min.js'); |
|
| 100 | + $this->requireJS($urlJs . '/jquery.serialize-object.min.js'); |
|
| 101 | 101 | |
| 102 | 102 | // Agile UI |
| 103 | 103 | $urlJs = $this->cdn['atk']?? $localJs; |
| 104 | 104 | $urlCss = $this->cdn['atk']?? $localCss; |
| 105 | - $this->requireJS($urlJs.'/atkjs-ui.min.js'); |
|
| 106 | - $this->requireCSS($urlCss.'/agileui.css'); |
|
| 105 | + $this->requireJS($urlJs . '/atkjs-ui.min.js'); |
|
| 106 | + $this->requireCSS($urlCss . '/agileui.css'); |
|
| 107 | 107 | |
| 108 | 108 | // Draggable |
| 109 | 109 | $urlJs = $this->cdn['draggable']?? $localJs; |
| 110 | - $this->requireJS($urlJs.'/draggable.bundle.js'); |
|
| 110 | + $this->requireJS($urlJs . '/draggable.bundle.js'); |
|
| 111 | 111 | |
| 112 | 112 | // jQuery niceScroll |
| 113 | 113 | $urlJs = $this->cdn['jquery-nicescroll']?? $localJs; |
| 114 | - $this->requireJS($urlJs.'/jquery.nicescroll.js'); |
|
| 114 | + $this->requireJS($urlJs . '/jquery.nicescroll.js'); |
|
| 115 | 115 | |
| 116 | 116 | // clipboard.js |
| 117 | 117 | $urlJs = $this->cdn['clipboardjs']?? $localJs; |
| 118 | - $this->requireJS($urlJs.'/clipboard.js'); |
|
| 118 | + $this->requireJS($urlJs . '/clipboard.js'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public function addCsrfToken() |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $key = md5(serialize(func_get_args())); |
| 194 | 194 | |
| 195 | - if (! isset($cache[$key])) { |
|
| 195 | + if (!isset($cache[$key])) { |
|
| 196 | 196 | $cache[$key] = true; |
| 197 | 197 | |
| 198 | 198 | parent::requireJS($url, $isAsync, $isDefer); |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | class SQL extends \atk4\data\Persistence\SQL |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Take a laravel connection and pass it to ATK Data |
|
| 12 | - * |
|
| 13 | - * @param \Illuminate\Database\DatabaseManager $db The Laravel database manager |
|
| 14 | - * |
|
| 15 | - * @return \atk4\data\Persistence_SQL |
|
| 16 | - * @throws \atk4\data\Exception |
|
| 17 | - * @throws \atk4\dsql\Exception |
|
| 18 | - */ |
|
| 19 | - public function __construct(DatabaseManager $database) |
|
| 20 | - { |
|
| 21 | - parent::__construct(Connection::connect($database->connection()->getPdo())); |
|
| 22 | - } |
|
| 10 | + /** |
|
| 11 | + * Take a laravel connection and pass it to ATK Data |
|
| 12 | + * |
|
| 13 | + * @param \Illuminate\Database\DatabaseManager $db The Laravel database manager |
|
| 14 | + * |
|
| 15 | + * @return \atk4\data\Persistence_SQL |
|
| 16 | + * @throws \atk4\data\Exception |
|
| 17 | + * @throws \atk4\dsql\Exception |
|
| 18 | + */ |
|
| 19 | + public function __construct(DatabaseManager $database) |
|
| 20 | + { |
|
| 21 | + parent::__construct(Connection::connect($database->connection()->getPdo())); |
|
| 22 | + } |
|
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |