1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - https://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace core\hook;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Moodle specific implementation of
|
|
|
21 |
* \Psr\EventDispatcher\StoppableEventInterface
|
|
|
22 |
* interface from PSR-14.
|
|
|
23 |
*
|
|
|
24 |
* @package core
|
|
|
25 |
* @author Petr Skoda
|
|
|
26 |
* @copyright 2023 Open LMS
|
|
|
27 |
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
28 |
*/
|
|
|
29 |
trait stoppable_trait {
|
|
|
30 |
/** @var bool $propagationstopped propagation is stopped */
|
|
|
31 |
private $propagationstopped = false;
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* Allows plugins to notify the hook dispatcher that hook propagation should be stopped
|
|
|
35 |
*/
|
|
|
36 |
public function stop_propagation(): void {
|
|
|
37 |
$this->propagationstopped = true;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Is propagation stopped?
|
|
|
42 |
*
|
|
|
43 |
* This will typically only be used by the Dispatcher to determine if the
|
|
|
44 |
* previous listener halted propagation.
|
|
|
45 |
* @return bool True if the Event is complete and no further listeners should be called.
|
|
|
46 |
* False to continue calling listeners.
|
|
|
47 |
*/
|
|
|
48 |
public function isPropagationStopped(): bool {
|
|
|
49 |
return $this->propagationstopped;
|
|
|
50 |
}
|
|
|
51 |
}
|