diff --git a/lib/vendor/composer/installed.json b/lib/vendor/composer/installed.json index c4887e0..a3b5791 100644 --- a/lib/vendor/composer/installed.json +++ b/lib/vendor/composer/installed.json @@ -175,18 +175,18 @@ "source": { "type": "git", "url": "https://github.com/Josantonius/PHP-Hook.git", - "reference": "c57c454a67429bd69393534de86ddaeb5982b365" + "reference": "c3489456ec2d964467ddc1ee75573b5f694537e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Josantonius/PHP-Hook/zipball/c57c454a67429bd69393534de86ddaeb5982b365", - "reference": "c57c454a67429bd69393534de86ddaeb5982b365", + "url": "https://api.github.com/repos/Josantonius/PHP-Hook/zipball/c3489456ec2d964467ddc1ee75573b5f694537e7", + "reference": "c3489456ec2d964467ddc1ee75573b5f694537e7", "shasum": "" }, "require": { "php": "^5.6 || ^7.0" }, - "time": "2017-06-24 17:22:23", + "time": "2017-06-26 02:16:52", "type": "library", "extra": { "branch-alias": { @@ -282,12 +282,12 @@ "source": { "type": "git", "url": "https://github.com/Eliasis-Framework/Module.git", - "reference": "2e022538fd75c55b592a5e3c0362c92ec730c13e" + "reference": "b6cb835d0bf097c90aa78a7b14d7e01451f52343" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Eliasis-Framework/Module/zipball/2e022538fd75c55b592a5e3c0362c92ec730c13e", - "reference": "2e022538fd75c55b592a5e3c0362c92ec730c13e", + "url": "https://api.github.com/repos/Eliasis-Framework/Module/zipball/b6cb835d0bf097c90aa78a7b14d7e01451f52343", + "reference": "b6cb835d0bf097c90aa78a7b14d7e01451f52343", "shasum": "" }, "require": { @@ -296,7 +296,7 @@ "josantonius/json": "^1.1.2", "php": "^5.6 || ^7.0" }, - "time": "2017-06-24 04:30:00", + "time": "2017-06-26 02:39:22", "type": "library", "extra": { "branch-alias": { @@ -446,12 +446,12 @@ "source": { "type": "git", "url": "https://github.com/Eliasis-Framework/Eliasis.git", - "reference": "c4caed0f6bb4dcf462e946d24fdd15138ae04991" + "reference": "c955eda920a03fb17af7abb9f119b5ace93ae675" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Eliasis-Framework/Eliasis/zipball/c4caed0f6bb4dcf462e946d24fdd15138ae04991", - "reference": "c4caed0f6bb4dcf462e946d24fdd15138ae04991", + "url": "https://api.github.com/repos/Eliasis-Framework/Eliasis/zipball/c955eda920a03fb17af7abb9f119b5ace93ae675", + "reference": "c955eda920a03fb17af7abb9f119b5ace93ae675", "shasum": "" }, "require": { diff --git a/lib/vendor/eliasis-framework/module/src/Module.php b/lib/vendor/eliasis-framework/module/src/Module.php index 4d12d10..373da92 100644 --- a/lib/vendor/eliasis-framework/module/src/Module.php +++ b/lib/vendor/eliasis-framework/module/src/Module.php @@ -181,12 +181,14 @@ private static function _add($module, $path) { $that->_getSettings(); - if (in_array($action, self::$hooks) || $state === 'active' || $state === 'outdated') { + $states = ['active', 'outdated']; - Hook::getInstance(App::$id); + if (in_array($action, self::$hooks) || in_array($state, $states)) { $that->_addResources(); + Hook::getInstance(App::$id); + Hook::doAction('module-load'); if (in_array($action, self::$hooks)) { @@ -320,27 +322,18 @@ private function _setAction($action) { * * @param string $action * @param string $state - * @param boolean $addAction */ - private function _doAction($action, $state, $addAction = false) { + private function _doAction($action, $state) { $that = self::getInstance(); - if ($addAction && isset($that->module['hooks'])) { + $Launcher = $that->instance('Launcher', 'controller'); - Hook::getInstance(App::$id); + if (is_object($Launcher) && method_exists($Launcher, $action)) { - foreach ($that->module['hooks'] as $hook) { - - if (isset($hook[0]) && $action === $hook[0]) { - - Hook::addActions($hook); - } - } + call_user_func([$Launcher, $action]); } - Hook::doAction($action); - $that->_setAction(''); $that->setState($state); @@ -357,9 +350,9 @@ private function _doAction($action, $state, $addAction = false) { * * @return string → module state */ - public static function remove($moduleName = null, $deleteAll = true) { + public static function remove($moduleName, $deleteAll = true) { - self::$id = ($moduleName) ? $moduleName : self::$id; + self::$id = $moduleName; $that = self::getInstance(); @@ -434,7 +427,7 @@ public static function changeState($moduleName = null) { $that->setState($state); - $that->_doAction($action, $state, true); + $that->_doAction($action, $state); return $state; } @@ -446,7 +439,7 @@ public static function changeState($moduleName = null) { * * @param boolean $modulePath → module path * @param boolean $deleteAll → delete the entire directory or - * leave only the configuration file. + * leave only the configuration file * * @return boolean */ @@ -463,25 +456,25 @@ private static function _deleteDir($modulePath, $deleteAll) { $objects = scandir($modulePath); - foreach ($objects as $object) { + foreach ($objects as $obj) { - if ($object === '.' || $object === '..') { continue; } + if ($obj === '.' || $obj === '..') { continue; } - if (is_file($modulePath . $object)) { + if (is_file($modulePath . $obj)) { if (!$deleteAll) { - if ($object == $slug.'.php' || $object == $slug.'.png') { + if ($obj == $slug . '.php' || $obj == $slug . '.png') { continue; } } - unlink($modulePath . $object); + unlink($modulePath . $obj); } else { - $that->_deleteDir($modulePath.$object.App::DS, $deleteAll); + $that->_deleteDir($modulePath . $obj . App::DS, $deleteAll); } } @@ -491,7 +484,9 @@ private static function _deleteDir($modulePath, $deleteAll) { $folder = array_pop($path); - if ($folder === $slug || $folder === 'images' || $folder === 'public') { + $folders = [$slug, 'images', 'public']; + + if (in_array($folder, $folders)) { return true; } @@ -601,6 +596,8 @@ private function _addResources() { if (isset($module['hooks'])) { + Hook::getInstance(App::$id); + Hook::addActions($module['hooks']); } diff --git a/lib/vendor/josantonius/hook/src/Hook.php b/lib/vendor/josantonius/hook/src/Hook.php index c0ce8a5..d796ec8 100644 --- a/lib/vendor/josantonius/hook/src/Hook.php +++ b/lib/vendor/josantonius/hook/src/Hook.php @@ -27,7 +27,7 @@ class Hook { * * @var int */ - protected static $id = 0; + protected static $id = '0'; /** * Callbacks. @@ -54,7 +54,7 @@ class Hook { * * @var string|false */ - protected $current = false; + protected static $current = false; /** * Method to use the singleton pattern and just create an instance. @@ -83,7 +83,7 @@ class Hook { * * @return object → instance */ - public static function getInstance($id = 0) { + public static function getInstance($id = '0') { self::$id = $id; @@ -174,7 +174,7 @@ public static function doAction($tag, $args = [], $remove = true) { $that = self::getInstance(self::$id); - $that->current = $tag; + self::$current = $tag; $that->actions['count']++; @@ -197,7 +197,7 @@ public static function doAction($tag, $args = [], $remove = true) { } } - $that->current = false; + self::$current = false; return (isset($action)) ? $action : false; } @@ -214,21 +214,19 @@ public static function doAction($tag, $args = [], $remove = true) { */ private function _runAction($action, $args) { - $that = self::getInstance(self::$id); - $function = $action['function']; $argsNumber = $action['arguments']; $class = (isset($function[0])) ? $function[0] : false; $method = (isset($function[1])) ? $function[1] : false; - $args = $that->_getArguments($argsNumber, $args); + $args = $this->_getArguments($argsNumber, $args); if (!($class && $method) && function_exists($function)) { return call_user_func($function, $args); - } else if ($obj = call_user_func([$class, $that->singleton])) { + } else if ($obj = call_user_func([$class, $this->singleton])) { if ($obj !== false) { @@ -255,15 +253,13 @@ private function _runAction($action, $args) { */ private function _getActions($tag, $remove) { - $that = self::getInstance(self::$id); - - if (isset($that->callbacks[$tag])) { + if (isset($this->callbacks[$tag])) { - $actions = $that->callbacks[$tag]; + $actions = $this->callbacks[$tag]; if ($remove) { - unset($that->callbacks[$tag]); + unset($this->callbacks[$tag]); } } @@ -315,8 +311,6 @@ private function _getArguments($argsNumber, $arguments) { */ public static function current() { - $that = self::getInstance(self::$id); - - return $that->current; + return self::$current; } }