Example #1
0
 /**
  * @param \Civi\API\Event\Event $event
  *   API preparation event.
  *
  * @throws \API_Exception
  */
 public function onApiPrepare(\Civi\API\Event\Event $event)
 {
     $apiRequest = $event->getApiRequest();
     // support multi-lingual requests
     if ($language = \CRM_Utils_Array::value('option.language', $apiRequest['params'])) {
         $this->setLocale($language);
     }
 }
 /**
  * @param \Civi\API\Event\Event $event
  *
  * @throws \Exception
  */
 public function onApiPrepare_validate(\Civi\API\Event\Event $event)
 {
     $apiRequest = $event->getApiRequest();
     // Not sure why this is omitted for generic actions. It would make sense to omit 'getfields', but that's only one generic action.
     if (isset($apiRequest['function']) && !$apiRequest['is_generic'] && isset($apiRequest['fields'])) {
         _civicrm_api3_validate_fields($apiRequest['entity'], $apiRequest['action'], $apiRequest['params'], $apiRequest['fields']);
         $event->setApiRequest($apiRequest);
     }
 }