]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Hook.php
Merge pull request #8055 from nupplaphil/task/remove_get_server
[friendica.git] / src / Core / Hook.php
index 7f0c015b3db155ae500b3ded2d06ecf0837c20d7..b8ad0fb8bd3b7d33399d671c0e111dfaaaf0af77 100644 (file)
@@ -5,13 +5,14 @@
 namespace Friendica\Core;
 
 use Friendica\App;
-use Friendica\BaseObject;
 use Friendica\Database\DBA;
+use Friendica\DI;
+use Friendica\Util\Strings;
 
 /**
  * Some functions to handle hooks
  */
-class Hook extends BaseObject
+class Hook
 {
        /**
         * Array of registered hooks
@@ -74,7 +75,7 @@ class Hook extends BaseObject
         */
        public static function register($hook, $file, $function, $priority = 0)
        {
-               $file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
+               $file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
 
                $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
                if (DBA::exists('hook', $condition)) {
@@ -97,7 +98,7 @@ class Hook extends BaseObject
         */
        public static function unregister($hook, $file, $function)
        {
-               $relative_file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
+               $relative_file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
 
                // This here is only needed for fixing a problem that existed on the develop branch
                $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
@@ -147,7 +148,7 @@ class Hook extends BaseObject
                                                if ($hook[0] != $fork_hook[0]) {
                                                        continue;
                                                }
-                                               self::callSingle(self::getApp(), 'hook_fork', $fork_hook, $hookdata);
+                                               self::callSingle(DI::app(), 'hook_fork', $fork_hook, $hookdata);
                                        }
 
                                        if (!$hookdata['execute']) {
@@ -174,7 +175,7 @@ class Hook extends BaseObject
        {
                if (array_key_exists($name, self::$hooks)) {
                        foreach (self::$hooks[$name] as $hook) {
-                               self::callSingle(self::getApp(), $name, $hook, $data);
+                               self::callSingle(DI::app(), $name, $hook, $data);
                        }
                }
        }
@@ -215,6 +216,8 @@ class Hook extends BaseObject
         */
        public static function isAddonApp($name)
        {
+               $name = Strings::sanitizeFilePathItem($name);
+
                if (array_key_exists('app_menu', self::$hooks)) {
                        foreach (self::$hooks['app_menu'] as $hook) {
                                if ($hook[0] == 'addon/' . $name . '/' . $name . '.php') {