blob: 6ad56ebad782c887e1f87bd83ec99e01d6646549 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Encryption;
use OCA\Encryption\Hooks\Contracts\IHook;
class HookManager {
/** @var IHook[] */
private $hookInstances = [];
/**
* @param array|IHook $instances
* - This accepts either a single instance of IHook or an array of instances of IHook
* @return bool
*/
public function registerHook($instances) {
if (is_array($instances)) {
foreach ($instances as $instance) {
if (!$instance instanceof IHook) {
return false;
}
$this->hookInstances[] = $instance;
}
} elseif ($instances instanceof IHook) {
$this->hookInstances[] = $instances;
}
return true;
}
public function fireHooks() {
foreach ($this->hookInstances as $instance) {
/**
* Fire off the add hooks method of each instance stored in cache
*/
$instance->addHooks();
}
}
}
|