@@ 22-45 (lines=24) @@ | ||
19 | * |
|
20 | * Event hooks may use this event to alter the result returned by the `action()` method. |
|
21 | */ |
|
22 | class ActionEvent extends Event |
|
23 | { |
|
24 | const TYPE = 'action'; |
|
25 | ||
26 | /** |
|
27 | * Reference to the result. |
|
28 | * |
|
29 | * @var mixed |
|
30 | */ |
|
31 | public $result; |
|
32 | ||
33 | /** |
|
34 | * The event is constructed with the type {@link self::TYPE}. |
|
35 | * |
|
36 | * @param Controller $target |
|
37 | * @param string $result |
|
38 | */ |
|
39 | public function __construct(Controller $target, &$result) |
|
40 | { |
|
41 | $this->result = &$result; |
|
42 | ||
43 | parent::__construct($target, self::TYPE); |
|
44 | } |
|
45 | } |
|
46 |
@@ 23-46 (lines=24) @@ | ||
20 | * Event hooks may use this event to alter the controller before the action is invoked, or provide |
|
21 | * a result and thus cancel the action. |
|
22 | */ |
|
23 | class BeforeActionEvent extends Event |
|
24 | { |
|
25 | const TYPE = 'action:before'; |
|
26 | ||
27 | /** |
|
28 | * Reference to the result. |
|
29 | * |
|
30 | * @var mixed |
|
31 | */ |
|
32 | public $result; |
|
33 | ||
34 | /** |
|
35 | * The event is constructed with the type {@link self::TYPE}. |
|
36 | * |
|
37 | * @param Controller $target |
|
38 | * @param string $result |
|
39 | */ |
|
40 | public function __construct(Controller $target, &$result) |
|
41 | { |
|
42 | $this->result = &$result; |
|
43 | ||
44 | parent::__construct($target, self::TYPE); |
|
45 | } |
|
46 | } |
|
47 |