Commit | Line | Data |
---|---|---|
19b53e5b C |
1 | <?php |
2 | ||
380f3545 TO |
3 | /* |
4 | +--------------------------------------------------------------------+ | |
41498ac5 | 5 | | Copyright CiviCRM LLC. All rights reserved. | |
380f3545 | 6 | | | |
41498ac5 TO |
7 | | This work is published under the GNU AGPLv3 license with some | |
8 | | permitted exceptions and without any warranty. For full license | | |
9 | | and copyright information, see https://civicrm.org/licensing | | |
380f3545 TO |
10 | +--------------------------------------------------------------------+ |
11 | */ | |
12 | ||
13 | /** | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
380f3545 TO |
17 | * $Id$ |
18 | * | |
19 | */ | |
20 | ||
21 | ||
19b53e5b C |
22 | namespace Civi\Api4\Utils; |
23 | ||
24 | class ActionUtil { | |
25 | ||
26 | /** | |
27 | * @param $entityName | |
28 | * @param $actionName | |
29 | * @return \Civi\Api4\Generic\AbstractAction | |
30 | * @throws \Civi\API\Exception\NotImplementedException | |
31 | */ | |
32 | public static function getAction($entityName, $actionName) { | |
33 | // For custom pseudo-entities | |
34 | if (strpos($entityName, 'Custom_') === 0) { | |
35 | return \Civi\Api4\CustomValue::$actionName(substr($entityName, 7)); | |
36 | } | |
37 | else { | |
38 | $callable = ["\\Civi\\Api4\\$entityName", $actionName]; | |
39 | if (!is_callable($callable)) { | |
40 | throw new \Civi\API\Exception\NotImplementedException("API ($entityName, $actionName) does not exist (join the API team and implement it!)"); | |
41 | } | |
42 | return call_user_func($callable); | |
43 | } | |
44 | } | |
45 | ||
46 | } |