1 | <?php |
||
2 | /* For licensing terms, see /license.txt */ |
||
3 | |||
4 | /** |
||
5 | * This file contains a Hook Event class for Admin Block. |
||
6 | * |
||
7 | * @package chamilo.library.hook |
||
8 | */ |
||
9 | |||
10 | /** |
||
11 | * Class HookAdminBlock |
||
12 | * This class is a Hook event implementing Admin Block Event interface. |
||
13 | * This class is used to modify admin block by notifying Hook Observer for Admin Block. |
||
14 | */ |
||
15 | class HookAdminBlock extends HookEvent implements HookAdminBlockEventInterface |
||
16 | { |
||
17 | /** |
||
18 | * Constructor. |
||
19 | */ |
||
20 | protected function __construct() |
||
21 | { |
||
22 | parent::__construct('HookAdminBlock'); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Notify Hook observers for Admin Block event. |
||
27 | * |
||
28 | * @param int $type Set the type of hook event called. |
||
29 | * 0: HOOK_EVENT_TYPE_PRE, 1: HOOK_EVENT_TYPE_POST |
||
30 | * |
||
31 | * @return array|int |
||
32 | */ |
||
33 | public function notifyAdminBlock($type) |
||
34 | { |
||
35 | /** @var \HookAdminBlockObserverInterface $observer */ |
||
36 | // Save data |
||
37 | if (isset($this->eventData['blocks'])) { |
||
38 | $this->eventData['type'] = $type; |
||
39 | // Call all registered hook observers for admin block |
||
40 | foreach ($this->observers as $observer) { |
||
41 | $data = $observer->hookAdminBlock($this); |
||
42 | if (isset($data['blocks'])) { |
||
43 | // Get modified data |
||
44 | $this->eventData['blocks'] = $data['blocks']; |
||
45 | } |
||
46 | } |
||
47 | |||
48 | return $this->eventData; |
||
0 ignored issues
–
show
|
|||
49 | } |
||
50 | |||
51 | return 0; |
||
52 | } |
||
53 | } |
||
54 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: