aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/legacy/OC_Hook.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/legacy/OC_Hook.php')
-rw-r--r--lib/private/legacy/OC_Hook.php49
1 files changed, 12 insertions, 37 deletions
diff --git a/lib/private/legacy/OC_Hook.php b/lib/private/legacy/OC_Hook.php
index cf0e9881e4c..e472b105498 100644
--- a/lib/private/legacy/OC_Hook.php
+++ b/lib/private/legacy/OC_Hook.php
@@ -1,37 +1,13 @@
<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Jakob Sack <mail@jakobsack.de>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Sam Tuke <mail@samtuke.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
/**
- * @deprecated 18.0.0 use events and the \OCP\EventDispatcher\IEventDispatcher service
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
+
+use Psr\Log\LoggerInterface;
+
class OC_Hook {
public static $thrownExceptions = [];
@@ -70,8 +46,8 @@ class OC_Hook {
}
// Connect the hook handler to the requested emitter
self::$registered[$signalClass][$signalName][] = [
- "class" => $slotClass,
- "name" => $slotName
+ 'class' => $slotClass,
+ 'name' => $slotName
];
// No chance for failure ;-)
@@ -85,13 +61,12 @@ class OC_Hook {
* @param string $signalName name of signal
* @param mixed $params default: array() array with additional data
* @return bool true if slots exists or false if not
- * @throws \OC\HintException
+ * @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException Emits a signal. To get data from the slot use references!
*
* TODO: write example
*/
public static function emit($signalClass, $signalName, $params = []) {
-
// Return false if no hook handlers are listening to this
// emitting class
if (!array_key_exists($signalClass, self::$registered)) {
@@ -107,11 +82,11 @@ class OC_Hook {
// Call all slots
foreach (self::$registered[$signalClass][$signalName] as $i) {
try {
- call_user_func([ $i["class"], $i["name"] ], $params);
+ call_user_func([ $i['class'], $i['name'] ], $params);
} catch (Exception $e) {
self::$thrownExceptions[] = $e;
- \OC::$server->getLogger()->logException($e);
- if ($e instanceof \OC\HintException) {
+ \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
+ if ($e instanceof \OCP\HintException) {
throw $e;
}
if ($e instanceof \OC\ServerNotAvailableException) {