X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FAPI%2FProvider%2FReflectionProvider.php;h=6eecafb79f7740c69e8b9e2711e5d4e1a8b7a76b;hb=081efd2df4eb2406f8ae1604ad31b501732a75f7;hp=676458faea696201e9196db6ec19609ea24dd0c1;hpb=f2a84e5c7c916f6c0d4c7fce69b844b019c17dd1;p=civicrm-core.git diff --git a/Civi/API/Provider/ReflectionProvider.php b/Civi/API/Provider/ReflectionProvider.php index 676458faea..6eecafb79f 100644 --- a/Civi/API/Provider/ReflectionProvider.php +++ b/Civi/API/Provider/ReflectionProvider.php @@ -63,7 +63,9 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface public function __construct($apiKernel) { $this->apiKernel = $apiKernel; $this->actions = array( + // FIXME: We really need to deal with the api's lack of uniformity wrt case (Entity or entity) 'Entity' => array('get', 'getactions'), + 'entity' => array('get', 'getactions'), '*' => array('getactions'), // 'getfields' ); } @@ -73,7 +75,7 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface */ public function onApiResolve(\Civi\API\Event\ResolveEvent $event) { $apiRequest = $event->getApiRequest(); - $actions = isset($this->actions[$apiRequest['entity']]) ? $this->actions[$apiRequest['entity']] : $this->actions['*']; + $actions = $this->getActionNames($apiRequest['version'], $apiRequest['entity']); if (in_array($apiRequest['action'], $actions)) { $apiRequest['is_metadata'] = TRUE; $event->setApiRequest($apiRequest); @@ -99,12 +101,12 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface * {inheritdoc} */ public function invoke($apiRequest) { - if ($apiRequest['entity'] == 'Entity' && $apiRequest['action'] == 'get') { - return civicrm_api3_create_success($this->apiKernel->getEntityNames($apiRequest['version'])); + if (strtolower($apiRequest['entity']) == 'entity' && $apiRequest['action'] == 'get') { + return civicrm_api3_create_success($this->apiKernel->getEntityNames($apiRequest['version']), $apiRequest['params'], 'entity', 'get'); } switch ($apiRequest['action']) { case 'getactions': - return civicrm_api3_create_success($this->apiKernel->getActionNames($apiRequest['version'], $apiRequest['entity'])); + return civicrm_api3_create_success($this->apiKernel->getActionNames($apiRequest['version'], $apiRequest['entity']), $apiRequest['params'], $apiRequest['entity'], $apiRequest['action']); // case 'getfields': // return $this->doGetFields($apiRequest); default: @@ -125,6 +127,7 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface * {inheritdoc} */ function getActionNames($version, $entity) { + $entity = _civicrm_api_get_camel_name($entity, $version); return isset($this->actions[$entity]) ? $this->actions[$entity] : $this->actions['*']; } }