namespace Civi\API\Subscriber;
use Civi\API\Events;
+use CRM_Core_DAO_AllCoreTables as AllCoreTables;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
*/
public static function getSubscribedEvents() {
return [
- Events::AUTHORIZE => [
+ 'civi.api.authorize' => [
['onApiAuthorize', Events::W_EARLY],
],
];
*/
public function __construct($kernel, $entityName, $actions, $lookupDelegateSql, $lookupCustomFieldSql, $allowedDelegates = NULL) {
$this->kernel = $kernel;
- $this->entityName = \CRM_Utils_String::convertStringToCamel($entityName);
+ $this->entityName = AllCoreTables::convertEntityNameToCamel($entityName, TRUE);
$this->actions = $actions;
$this->lookupDelegateSql = $lookupDelegateSql;
$this->lookupCustomFieldSql = $lookupCustomFieldSql;
*/
public function onApiAuthorize(\Civi\API\Event\AuthorizeEvent $event) {
$apiRequest = $event->getApiRequest();
- if ($apiRequest['version'] == 3 && \CRM_Utils_String::convertStringToCamel($apiRequest['entity']) == $this->entityName && in_array(strtolower($apiRequest['action']), $this->actions)) {
+ if ($apiRequest['version'] == 3 && AllCoreTables::convertEntityNameToCamel($apiRequest['entity'], TRUE) == $this->entityName && in_array(strtolower($apiRequest['action']), $this->actions)) {
if (isset($apiRequest['params']['field_name'])) {
$fldIdx = \CRM_Utils_Array::index(['field_name'], $this->getCustomFields());
if (empty($fldIdx[$apiRequest['params']['field_name']])) {
}
if (isset($apiRequest['params']['entity_table'])) {
- if (!\CRM_Core_DAO_AllCoreTables::isCoreTable($apiRequest['params']['entity_table'])) {
- throw new \API_Exception("Unrecognized target entity table {$apiRequest['params']['entity_table']}");
- }
$this->authorizeDelegate(
$apiRequest['action'],
$apiRequest['params']['entity_table'],