Commit | Line | Data |
---|---|---|
132ec342 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
41498ac5 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
132ec342 | 5 | | | |
41498ac5 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
132ec342 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
132ec342 TO |
11 | |
12 | namespace Civi\API\Event; | |
13 | ||
6550386a EM |
14 | /** |
15 | * Class AuthorizeEvent | |
16 | * @package Civi\API\Event | |
39b870b8 TO |
17 | * |
18 | * Determine whether the API request is allowed for the current user. | |
19 | * For successful execution, at least one listener must invoke | |
20 | * $event->authorize(). | |
21 | * | |
22 | * Event name: 'civi.api.authorize' | |
6550386a | 23 | */ |
132ec342 TO |
24 | class AuthorizeEvent extends Event { |
25 | /** | |
26 | * @var bool | |
27 | */ | |
28 | private $authorized = FALSE; | |
29 | ||
8882ff5c TO |
30 | /** |
31 | * Mark the request as authorized. | |
32 | */ | |
132ec342 TO |
33 | public function authorize() { |
34 | $this->authorized = TRUE; | |
35 | } | |
36 | ||
37 | /** | |
8882ff5c TO |
38 | * @return bool |
39 | * TRUE if the request has been authorized. | |
132ec342 TO |
40 | */ |
41 | public function isAuthorized() { | |
42 | return $this->authorized; | |
43 | } | |
96025800 | 44 | |
132ec342 | 45 | } |