*/
namespace Civi\API;
-use Civi\Api4\Event\CreateApi4RequestEvent;
+use Civi\Api4\Utils\CoreUtil;
/**
* Class Request
];
case 4:
- // Load the API kernel service for registering API providers, as
- // otherwise subscribers to the civi.api4.createRequest event registered
- // through the EventSubscriberInterface will not be registered.
- \Civi::service('civi_api_kernel');
- $e = new CreateApi4RequestEvent($entity);
- \Civi::dispatcher()->dispatch('civi.api4.createRequest', $e);
- $callable = [$e->className, $action];
- if (!$e->className || !is_callable($callable)) {
+ $className = CoreUtil::getApiClass($entity);
+ $callable = [$className, $action];
+ if (!$className || !is_callable($callable)) {
throw new \Civi\API\Exception\NotImplementedException("API ($entity, $action) does not exist (join the API team and implement it!)");
}
// Check enabled components
if ($daoName && defined("{$daoName}::COMPONENT") && !\CRM_Core_Component::isEnabled($daoName::COMPONENT)) {
throw new \Civi\API\Exception\NotImplementedException("$entity API is not available because " . $daoName::COMPONENT . " component is disabled");
}
- $apiRequest = call_user_func_array($callable, $e->args);
+ $args = (array) CoreUtil::getInfoItem($entity, 'class_args');
+ $apiRequest = call_user_func_array($callable, $args);
foreach ($params as $name => $param) {
$setter = 'set' . ucfirst($name);
$apiRequest->$setter($param);