@@ -24,11 +24,11 @@ |
||
| 24 | 24 | |
| 25 | 25 | public function migrate() |
| 26 | 26 | { |
| 27 | - Model\Module::migrate(); |
|
| 27 | + Model\Module::migrate(); |
|
| 28 | 28 | |
| 29 | - Model\Variable::migrate(); |
|
| 29 | + Model\Variable::migrate(); |
|
| 30 | 30 | |
| 31 | - return parent::migrate(); |
|
| 31 | + return parent::migrate(); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class Variable extends Model |
| 10 | 10 | { |
| 11 | - use HasEpesiConnection; |
|
| 11 | + use HasEpesiConnection; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @var Collection |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | protected function init(): void |
| 29 | 29 | { |
| 30 | - parent::init(); |
|
| 30 | + parent::init(); |
|
| 31 | 31 | |
| 32 | - $this->addFields([ |
|
| 33 | - 'name', |
|
| 34 | - 'value' => ['type' => 'text', 'serialize' => 'json'] |
|
| 35 | - ]); |
|
| 32 | + $this->addFields([ |
|
| 33 | + 'name', |
|
| 34 | + 'value' => ['type' => 'text', 'serialize' => 'json'] |
|
| 35 | + ]); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public static function recall($name, $default = null) { |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | $variable = self::create()->addCondition('name', $name)->tryLoadAny(); |
| 58 | 58 | |
| 59 | 59 | if ($variable->loaded()) { |
| 60 | - $variable->save(compact('value')); |
|
| 60 | + $variable->save(compact('value')); |
|
| 61 | 61 | } |
| 62 | 62 | else { |
| 63 | - $variable->insert(compact('name', 'value')); |
|
| 63 | + $variable->insert(compact('name', 'value')); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public $strict_types = false; |
| 21 | 21 | |
| 22 | 22 | private static function cache() { |
| 23 | - if(isset(self::$variables)) return; |
|
| 23 | + if (isset(self::$variables)) return; |
|
| 24 | 24 | |
| 25 | 25 | self::$variables = self::pluck('value', 'name'); |
| 26 | 26 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public static function forget($name, $throwError=true) { |
|
| 67 | + public static function forget($name, $throwError = true) { |
|
| 68 | 68 | self::cache(); |
| 69 | 69 | |
| 70 | 70 | if (!self::$variables->has($name) && $throwError) { |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | public $strict_types = false; |
| 21 | 21 | |
| 22 | 22 | private static function cache() { |
| 23 | - if(isset(self::$variables)) return; |
|
| 23 | + if(isset(self::$variables)) { |
|
| 24 | + return; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | self::$variables = self::pluck('value', 'name'); |
| 26 | 28 | } |
@@ -38,7 +40,9 @@ discard block |
||
| 38 | 40 | public static function recall($name, $default = null) { |
| 39 | 41 | self::cache(); |
| 40 | 42 | |
| 41 | - if (!self::$variables->has($name)) return $default; |
|
| 43 | + if (!self::$variables->has($name)) { |
|
| 44 | + return $default; |
|
| 45 | + } |
|
| 42 | 46 | |
| 43 | 47 | return self::$variables->get($name, $default) ?? $default; |
| 44 | 48 | } |
@@ -58,8 +62,7 @@ discard block |
||
| 58 | 62 | |
| 59 | 63 | if ($variable->loaded()) { |
| 60 | 64 | $variable->save(compact('value')); |
| 61 | - } |
|
| 62 | - else { |
|
| 65 | + } else { |
|
| 63 | 66 | $variable->insert(compact('name', 'value')); |
| 64 | 67 | } |
| 65 | 68 | } |
@@ -7,19 +7,19 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Module extends Model |
| 9 | 9 | { |
| 10 | - use HasEpesiConnection; |
|
| 10 | + use HasEpesiConnection; |
|
| 11 | 11 | |
| 12 | - public $table = 'modules'; |
|
| 12 | + public $table = 'modules'; |
|
| 13 | 13 | |
| 14 | - protected function init(): void |
|
| 15 | - { |
|
| 16 | - parent::init(); |
|
| 14 | + protected function init(): void |
|
| 15 | + { |
|
| 16 | + parent::init(); |
|
| 17 | 17 | |
| 18 | - $this->addFields([ |
|
| 19 | - 'class', |
|
| 20 | - 'alias', |
|
| 21 | - 'priority' => ['default' => 0], |
|
| 22 | - 'state' => ['default' => 1] |
|
| 23 | - ]); |
|
| 24 | - } |
|
| 18 | + $this->addFields([ |
|
| 19 | + 'class', |
|
| 20 | + 'alias', |
|
| 21 | + 'priority' => ['default' => 0], |
|
| 22 | + 'state' => ['default' => 1] |
|
| 23 | + ]); |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -7,18 +7,18 @@ |
||
| 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 | - * @return \atk4\data\Persistence\SQL |
|
| 14 | - */ |
|
| 15 | - public function __construct(DatabaseManager $database) |
|
| 16 | - { |
|
| 17 | - $pdo = $database->connection()->getPdo(); |
|
| 10 | + /** |
|
| 11 | + * Take a laravel connection and pass it to ATK Data |
|
| 12 | + * |
|
| 13 | + * @return \atk4\data\Persistence\SQL |
|
| 14 | + */ |
|
| 15 | + public function __construct(DatabaseManager $database) |
|
| 16 | + { |
|
| 17 | + $pdo = $database->connection()->getPdo(); |
|
| 18 | 18 | |
| 19 | - // temporary fix of atk4/data inability to handle PREPARE on 'is null' |
|
| 20 | - $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true); |
|
| 19 | + // temporary fix of atk4/data inability to handle PREPARE on 'is null' |
|
| 20 | + $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true); |
|
| 21 | 21 | |
| 22 | - parent::__construct(Connection::connect($pdo)); |
|
| 23 | - } |
|
| 22 | + parent::__construct(Connection::connect($pdo)); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -27,27 +27,27 @@ |
||
| 27 | 27 | return new JsModal($this->title, $this->virtualPage); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - protected function getContents(VirtualPage $vp) |
|
| 31 | - { |
|
| 32 | - $vp->add([ |
|
| 33 | - new LaunchButton([ |
|
| 34 | - 'label' => 'Test Button 1', |
|
| 35 | - 'icon' => 'user' |
|
| 36 | - ]) |
|
| 37 | - ])->link(URL::to('/')); |
|
| 30 | + protected function getContents(VirtualPage $vp) |
|
| 31 | + { |
|
| 32 | + $vp->add([ |
|
| 33 | + new LaunchButton([ |
|
| 34 | + 'label' => 'Test Button 1', |
|
| 35 | + 'icon' => 'user' |
|
| 36 | + ]) |
|
| 37 | + ])->link(URL::to('/')); |
|
| 38 | 38 | |
| 39 | - $vp->add([ |
|
| 40 | - new LaunchButton([ |
|
| 41 | - 'label' => 'Test Button 2', |
|
| 42 | - 'icon' => 'car' |
|
| 43 | - ]) |
|
| 44 | - ]); |
|
| 39 | + $vp->add([ |
|
| 40 | + new LaunchButton([ |
|
| 41 | + 'label' => 'Test Button 2', |
|
| 42 | + 'icon' => 'car' |
|
| 43 | + ]) |
|
| 44 | + ]); |
|
| 45 | 45 | |
| 46 | - $vp->add([ |
|
| 47 | - new LaunchButton([ |
|
| 48 | - 'label' => 'Test Button 3', |
|
| 49 | - 'icon' => 'bus' |
|
| 50 | - ]) |
|
| 51 | - ]); |
|
| 52 | - } |
|
| 46 | + $vp->add([ |
|
| 47 | + new LaunchButton([ |
|
| 48 | + 'label' => 'Test Button 3', |
|
| 49 | + 'icon' => 'bus' |
|
| 50 | + ]) |
|
| 51 | + ]); |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -10,53 +10,53 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class LayoutView extends \atk4\ui\Layout |
| 12 | 12 | { |
| 13 | - use SessionTrait; |
|
| 13 | + use SessionTrait; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var View\NavMenu |
|
| 17 | - */ |
|
| 18 | - public $menuLeft; // vertical menu |
|
| 15 | + /** |
|
| 16 | + * @var View\NavMenu |
|
| 17 | + */ |
|
| 18 | + public $menuLeft; // vertical menu |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var \atk4\ui\Menu |
|
| 22 | - */ |
|
| 23 | - public $menuTop; // horizontal menu |
|
| 20 | + /** |
|
| 21 | + * @var \atk4\ui\Menu |
|
| 22 | + */ |
|
| 23 | + public $menuTop; // horizontal menu |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var \atk4\ui\Menu |
|
| 27 | - */ |
|
| 28 | - public $menuRight; // vertical pull-down |
|
| 25 | + /** |
|
| 26 | + * @var \atk4\ui\Menu |
|
| 27 | + */ |
|
| 28 | + public $menuRight; // vertical pull-down |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var View\ActionBar |
|
| 32 | - */ |
|
| 33 | - public $actionBar; |
|
| 34 | - public $locationBar; |
|
| 30 | + /** |
|
| 31 | + * @var View\ActionBar |
|
| 32 | + */ |
|
| 33 | + public $actionBar; |
|
| 34 | + public $locationBar; |
|
| 35 | 35 | |
| 36 | - public $burger = true; // burger menu item |
|
| 36 | + public $burger = true; // burger menu item |
|
| 37 | 37 | |
| 38 | - /* |
|
| 38 | + /* |
|
| 39 | 39 | * Whether or not left Menu is visible on Page load. |
| 40 | 40 | */ |
| 41 | - public $isMenuLeftVisible = true; |
|
| 41 | + public $isMenuLeftVisible = true; |
|
| 42 | 42 | |
| 43 | - public $defaultTemplate = 'layout/admin.html'; |
|
| 43 | + public $defaultTemplate = 'layout/admin.html'; |
|
| 44 | 44 | |
| 45 | - protected $location; |
|
| 45 | + protected $location; |
|
| 46 | 46 | |
| 47 | - protected function init(): void |
|
| 48 | - { |
|
| 49 | - parent::init(); |
|
| 47 | + protected function init(): void |
|
| 48 | + { |
|
| 49 | + parent::init(); |
|
| 50 | 50 | |
| 51 | - $this->initMenuTop(); |
|
| 52 | - $this->initActionBar(); |
|
| 51 | + $this->initMenuTop(); |
|
| 52 | + $this->initActionBar(); |
|
| 53 | 53 | |
| 54 | 54 | // if (request()->pjax()) return; |
| 55 | 55 | |
| 56 | - $this->initMenuLeft(); |
|
| 57 | - $this->initMenuRight(); |
|
| 56 | + $this->initMenuLeft(); |
|
| 57 | + $this->initMenuRight(); |
|
| 58 | 58 | |
| 59 | - $this->template->trySet('version', $this->getApp()->version); |
|
| 59 | + $this->template->trySet('version', $this->getApp()->version); |
|
| 60 | 60 | |
| 61 | 61 | // $this->js(true, null, 'body')->niceScroll(); |
| 62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | // if (event.originalEvent.persisted) { |
| 66 | 66 | // window.location.reload(); |
| 67 | 67 | // }')])); |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @return static |
@@ -127,40 +127,40 @@ discard block |
||
| 127 | 127 | $this->menuRight = $this->menuTop->add(new View\RightMenu(['ui' => false]), 'RightMenu')->addClass('right menu')->removeClass('item'); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - protected function initMenuLeft() |
|
| 131 | - { |
|
| 132 | - if ($this->menuLeft) return; |
|
| 130 | + protected function initMenuLeft() |
|
| 131 | + { |
|
| 132 | + if ($this->menuLeft) return; |
|
| 133 | 133 | |
| 134 | - $this->menuLeft = View\NavMenu::addTo($this, 'left vertical labeled sidebar', ['LeftMenu']); |
|
| 134 | + $this->menuLeft = View\NavMenu::addTo($this, 'left vertical labeled sidebar', ['LeftMenu']); |
|
| 135 | 135 | |
| 136 | - if ($this->burger) { |
|
| 137 | - $this->isMenuLeftVisible = $this->learn('menu', $this->isMenuLeftVisible); |
|
| 136 | + if ($this->burger) { |
|
| 137 | + $this->isMenuLeftVisible = $this->learn('menu', $this->isMenuLeftVisible); |
|
| 138 | 138 | |
| 139 | - $this->burger->add([\atk4\ui\Icon::class, 'content'])->on('click', [ |
|
| 140 | - (new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
|
| 141 | - (new jQuery('.epesi-logo'))->toggleClass('expanded'), |
|
| 142 | - (new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
|
| 143 | - \atk4\ui\JsCallback::addTo($this->burger)->set(function($jsCallback, $visible) { |
|
| 144 | - $this->memorize('menu', filter_var($visible, FILTER_VALIDATE_BOOLEAN)); |
|
| 145 | - }, [$this->menuLeft->js(true)->hasClass('visible')]) |
|
| 146 | - ]); |
|
| 147 | - } |
|
| 148 | - } |
|
| 139 | + $this->burger->add([\atk4\ui\Icon::class, 'content'])->on('click', [ |
|
| 140 | + (new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
|
| 141 | + (new jQuery('.epesi-logo'))->toggleClass('expanded'), |
|
| 142 | + (new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
|
| 143 | + \atk4\ui\JsCallback::addTo($this->burger)->set(function($jsCallback, $visible) { |
|
| 144 | + $this->memorize('menu', filter_var($visible, FILTER_VALIDATE_BOOLEAN)); |
|
| 145 | + }, [$this->menuLeft->js(true)->hasClass('visible')]) |
|
| 146 | + ]); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - protected function initActionBar() |
|
| 151 | - { |
|
| 152 | - if (!$this->actionBar) { |
|
| 153 | - $this->actionBar = View\ActionBar::addTo($this, [], ['ActionBar']); |
|
| 154 | - } |
|
| 150 | + protected function initActionBar() |
|
| 151 | + { |
|
| 152 | + if (!$this->actionBar) { |
|
| 153 | + $this->actionBar = View\ActionBar::addTo($this, [], ['ActionBar']); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - return $this; |
|
| 157 | - } |
|
| 156 | + return $this; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - public function renderView(): void |
|
| 160 | - { |
|
| 161 | - if ($this->menuLeft && $this->isMenuLeftVisible) { |
|
| 162 | - $this->menuLeft->addClass('visible'); |
|
| 163 | - } |
|
| 164 | - parent::renderView(); |
|
| 165 | - } |
|
| 159 | + public function renderView(): void |
|
| 160 | + { |
|
| 161 | + if ($this->menuLeft && $this->isMenuLeftVisible) { |
|
| 162 | + $this->menuLeft->addClass('visible'); |
|
| 163 | + } |
|
| 164 | + parent::renderView(); |
|
| 165 | + } |
|
| 166 | 166 | } |
@@ -15,17 +15,17 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @var View\NavMenu |
| 17 | 17 | */ |
| 18 | - public $menuLeft; // vertical menu |
|
| 18 | + public $menuLeft; // vertical menu |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @var \atk4\ui\Menu |
| 22 | 22 | */ |
| 23 | - public $menuTop; // horizontal menu |
|
| 23 | + public $menuTop; // horizontal menu |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @var \atk4\ui\Menu |
| 27 | 27 | */ |
| 28 | - public $menuRight; // vertical pull-down |
|
| 28 | + public $menuRight; // vertical pull-down |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @var View\ActionBar |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public $actionBar; |
| 34 | 34 | public $locationBar; |
| 35 | 35 | |
| 36 | - public $burger = true; // burger menu item |
|
| 36 | + public $burger = true; // burger menu item |
|
| 37 | 37 | |
| 38 | 38 | /* |
| 39 | 39 | * Whether or not left Menu is visible on Page load. |
@@ -100,7 +100,9 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | protected function initMenuTop() |
| 102 | 102 | { |
| 103 | - if ($this->menuTop) return; |
|
| 103 | + if ($this->menuTop) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | $this->menuTop = Menu::addTo($this, ['atk-topMenu fixed horizontal', 'element' => 'header'], ['TopMenu']); |
| 106 | 108 | |
@@ -122,14 +124,18 @@ discard block |
||
| 122 | 124 | |
| 123 | 125 | protected function initMenuRight() |
| 124 | 126 | { |
| 125 | - if ($this->menuRight) return; |
|
| 127 | + if ($this->menuRight) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $this->menuRight = $this->menuTop->add(new View\RightMenu(['ui' => false]), 'RightMenu')->addClass('right menu')->removeClass('item'); |
| 128 | 132 | } |
| 129 | 133 | |
| 130 | 134 | protected function initMenuLeft() |
| 131 | 135 | { |
| 132 | - if ($this->menuLeft) return; |
|
| 136 | + if ($this->menuLeft) { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 133 | 139 | |
| 134 | 140 | $this->menuLeft = View\NavMenu::addTo($this, 'left vertical labeled sidebar', ['LeftMenu']); |
| 135 | 141 | |
@@ -2,35 +2,35 @@ |
||
| 2 | 2 | |
| 3 | 3 | if (! function_exists('ui')) { |
| 4 | 4 | function ui() : Epesi\Core\UI |
| 5 | - { |
|
| 6 | - return resolve(Epesi\Core\UI::class); |
|
| 7 | - } |
|
| 5 | + { |
|
| 6 | + return resolve(Epesi\Core\UI::class); |
|
| 7 | + } |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | if (! function_exists('eval_css')) { |
| 11 | 11 | function eval_css($css) |
| 12 | - { |
|
| 13 | - ui()->addStyle($css); |
|
| 14 | - } |
|
| 12 | + { |
|
| 13 | + ui()->addStyle($css); |
|
| 14 | + } |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | if (! function_exists('eval_js')) { |
| 18 | 18 | function eval_js($js, $args = []) |
| 19 | - { |
|
| 20 | - ui()->addJs($js, $args); |
|
| 21 | - } |
|
| 19 | + { |
|
| 20 | + ui()->addJs($js, $args); |
|
| 21 | + } |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (! function_exists('load_css')) { |
| 25 | 25 | function load_css($url) |
| 26 | - { |
|
| 27 | - return ui()->requireCss($url); |
|
| 28 | - } |
|
| 26 | + { |
|
| 27 | + return ui()->requireCss($url); |
|
| 28 | + } |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | if (! function_exists('load_js')) { |
| 32 | 32 | function load_js($url) |
| 33 | - { |
|
| 34 | - return ui()->requireJs($url); |
|
| 35 | - } |
|
| 33 | + { |
|
| 34 | + return ui()->requireJs($url); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -1,34 +1,34 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (! function_exists('ui')) { |
|
| 3 | +if (!function_exists('ui')) { |
|
| 4 | 4 | function ui() : Epesi\Core\UI |
| 5 | 5 | { |
| 6 | 6 | return resolve(Epesi\Core\UI::class); |
| 7 | 7 | } |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -if (! function_exists('eval_css')) { |
|
| 10 | +if (!function_exists('eval_css')) { |
|
| 11 | 11 | function eval_css($css) |
| 12 | 12 | { |
| 13 | 13 | ui()->addStyle($css); |
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -if (! function_exists('eval_js')) { |
|
| 17 | +if (!function_exists('eval_js')) { |
|
| 18 | 18 | function eval_js($js, $args = []) |
| 19 | 19 | { |
| 20 | 20 | ui()->addJs($js, $args); |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -if (! function_exists('load_css')) { |
|
| 24 | +if (!function_exists('load_css')) { |
|
| 25 | 25 | function load_css($url) |
| 26 | 26 | { |
| 27 | 27 | return ui()->requireCss($url); |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -if (! function_exists('load_js')) { |
|
| 31 | +if (!function_exists('load_js')) { |
|
| 32 | 32 | function load_js($url) |
| 33 | 33 | { |
| 34 | 34 | return ui()->requireJs($url); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | return self::$installed = self::$installed ?? self::getCached('epesi-modules-installed', function() { |
| 56 | 56 | try { |
| 57 | - $installedModules = Module::pluck('class', 'alias'); |
|
| 57 | + $installedModules = Module::pluck('class', 'alias'); |
|
| 58 | 58 | } catch (\Exception $e) { |
| 59 | 59 | $installedModules = collect(); |
| 60 | 60 | } |
@@ -87,32 +87,31 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | protected static function discoverModuleClasses(string $namespace, string $basePath): array |
| 89 | 89 | { |
| 90 | - $ret = collect(); |
|
| 90 | + $ret = collect(); |
|
| 91 | 91 | |
| 92 | - $moduleNamespace = trim($namespace, '\\'); |
|
| 92 | + $moduleNamespace = trim($namespace, '\\'); |
|
| 93 | 93 | |
| 94 | - $names = array_slice(explode('\\', $moduleNamespace), - 1); |
|
| 94 | + $names = array_slice(explode('\\', $moduleNamespace), - 1); |
|
| 95 | 95 | |
| 96 | - if ($name = $names? reset($names): '') { |
|
| 97 | - $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
|
| 96 | + if ($name = $names? reset($names): '') { |
|
| 97 | + $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
|
| 98 | 98 | |
| 99 | - if (is_subclass_of($moduleClass, ModuleCore::class)) { |
|
| 100 | - $ret->add($moduleClass); |
|
| 101 | - } |
|
| 102 | - } |
|
| 99 | + if (is_subclass_of($moduleClass, ModuleCore::class)) { |
|
| 100 | + $ret->add($moduleClass); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
| 105 | - $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
|
| 104 | + foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
| 105 | + $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
|
| 106 | 106 | |
| 107 | - $ret = $ret->merge(self::discoverModuleClasses($subModuleNamespace, $path)); |
|
| 108 | - } |
|
| 107 | + $ret = $ret->merge(self::discoverModuleClasses($subModuleNamespace, $path)); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - return $ret->all(); |
|
| 110 | + return $ret->all(); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * Common method to use for caching of data within module manager |
| 115 | - |
|
| 116 | 115 | * @return mixed |
| 117 | 116 | */ |
| 118 | 117 | protected static function getCached(string $key, \Closure $default) |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public static function getClass(string $classOrAlias, bool $installedOnly = false): ?string |
| 40 | 40 | { |
| 41 | - $modules = $installedOnly? self::getInstalled(): self::getAll(); |
|
| 41 | + $modules = $installedOnly ? self::getInstalled() : self::getAll(); |
|
| 42 | 42 | |
| 43 | 43 | if (collect($modules)->contains($classOrAlias)) { |
| 44 | 44 | return $classOrAlias; |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public static function getAll(): array |
| 70 | 70 | { |
| 71 | - return self::getCached('epesi-modules-available', function () { |
|
| 71 | + return self::getCached('epesi-modules-available', function() { |
|
| 72 | 72 | $modules = collect(); |
| 73 | - foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules()?: []) as $namespace => $path) { |
|
| 73 | + foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules() ?: []) as $namespace => $path) { |
|
| 74 | 74 | foreach (self::discoverModuleClasses($namespace, $path) as $moduleClass) { |
| 75 | 75 | $modules->add(['alias' => $moduleClass::alias(), 'class' => $moduleClass]); |
| 76 | 76 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $names = array_slice(explode('\\', $moduleNamespace), - 1); |
| 95 | 95 | |
| 96 | - if ($name = $names? reset($names): '') { |
|
| 96 | + if ($name = $names ? reset($names) : '') { |
|
| 97 | 97 | $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
| 98 | 98 | |
| 99 | 99 | if (is_subclass_of($moduleClass, ModuleCore::class)) { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
| 104 | + foreach (glob($basePath . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $path) { |
|
| 105 | 105 | $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
| 106 | 106 | |
| 107 | 107 | $ret = $ret->merge(self::discoverModuleClasses($subModuleNamespace, $path)); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected static function getCached(string $key, \Closure $default) |
| 119 | 119 | { |
| 120 | - if (! Cache::has($key)) { |
|
| 120 | + if (!Cache::has($key)) { |
|
| 121 | 121 | Cache::forever($key, $default()); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $installedModules = collect(self::getInstalled()); |
| 153 | 153 | |
| 154 | 154 | // if epesi is not installed fake having the system module to enable its functionality |
| 155 | - if (! $installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 155 | + if (!$installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 156 | 156 | $installedModules = collect([ |
| 157 | 157 | 'system' => \Epesi\Core\System\SystemCore::class |
| 158 | 158 | ]); |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $ret = []; |
| 162 | 162 | foreach ($installedModules as $module) { |
| 163 | - if (! $list = $module::$method(...$args)) continue; |
|
| 163 | + if (!$list = $module::$method(...$args)) continue; |
|
| 164 | 164 | |
| 165 | - $ret = array_merge($ret, is_array($list)? $list: [$list]); |
|
| 165 | + $ret = array_merge($ret, is_array($list) ? $list : [$list]); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $ret; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | return true; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 182 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 183 | 183 | throw new \Exception(sprintf('Module "%s" could not be identified', $classOrAlias)); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | ]); |
| 210 | 210 | |
| 211 | 211 | if ($installRecommended) { |
| 212 | - $installRecommended = is_array($installRecommended)? $installRecommended: $module->recommended(); |
|
| 212 | + $installRecommended = is_array($installRecommended) ? $installRecommended : $module->recommended(); |
|
| 213 | 213 | |
| 214 | 214 | foreach ($installRecommended as $recommendedModule) { |
| 215 | 215 | try { |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | while ($unsatisfiedDependencies = self::unsatisfiedDependencies($moduleClass)) { |
| 239 | 239 | $parentModule = array_shift($unsatisfiedDependencies); |
| 240 | 240 | |
| 241 | - if (self::$processing[$parentModule]?? false) { |
|
| 241 | + if (self::$processing[$parentModule] ?? false) { |
|
| 242 | 242 | throw new \Exception(sprintf('Cross dependency: %s', $parentModule)); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if (! self::isAvailable($parentModule)) { |
|
| 245 | + if (!self::isAvailable($parentModule)) { |
|
| 246 | 246 | throw new \Exception(sprintf('Module "%s" not found!', $parentModule)); |
| 247 | 247 | } |
| 248 | 248 | |
@@ -314,17 +314,17 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | public static function uninstall(string $classOrAlias): bool |
| 316 | 316 | { |
| 317 | - if (! self::isInstalled($classOrAlias)) { |
|
| 317 | + if (!self::isInstalled($classOrAlias)) { |
|
| 318 | 318 | print sprintf('Module "%s" is not installed!', $classOrAlias); |
| 319 | 319 | |
| 320 | 320 | return true; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 323 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 324 | 324 | throw new \Exception(sprintf('Module "%s" could not be identified', $classOrAlias)); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - foreach (self::listDependents()[$moduleClass]?? [] as $childModule) { |
|
| 327 | + foreach (self::listDependents()[$moduleClass] ?? [] as $childModule) { |
|
| 328 | 328 | self::uninstall($childModule); |
| 329 | 329 | } |
| 330 | 330 | |
@@ -160,7 +160,9 @@ |
||
| 160 | 160 | |
| 161 | 161 | $ret = []; |
| 162 | 162 | foreach ($installedModules as $module) { |
| 163 | - if (! $list = $module::$method(...$args)) continue; |
|
| 163 | + if (! $list = $module::$method(...$args)) { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 164 | 166 | |
| 165 | 167 | $ret = array_merge($ret, is_array($list)? $list: [$list]); |
| 166 | 168 | } |