Skip to content
Snippets Groups Projects
Commit 72a269aa authored by jaapjansma's avatar jaapjansma
Browse files

Getfields returned wrong type

parent a0c3995d
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,7 @@ class Api implements OutputInterface, API_ProviderInterface, EventSubscriberInte
$apiRequest = $event->getApiRequest();
$params = $apiRequest['params'];
$result = $event->getResponse();
$types = \CRM_Utils_Type::getValidTypes();
// First check whether the entity is dataprocessorapi and the action is getfields.
// If not return this function.
......@@ -96,11 +97,15 @@ class Api implements OutputInterface, API_ProviderInterface, EventSubscriberInte
foreach ($dataProcessor->getDataFlow()->getOutputFieldHandlers() as $outputFieldHandler) {
$fieldSpec = $outputFieldHandler->getOutputFieldSpecification();
$type = \CRM_Utils_Type::T_STRING;
if (isset($types[$fieldSpec->type])) {
$type = $types[$fieldSpec->type];
}
$field = [
'name' => $fieldSpec->alias,
'title' => $fieldSpec->title,
'description' => '',
'type' => $fieldSpec->type,
'type' => $type,
'api.required' => FALSE,
'api.aliases' => [],
'api.filter' => FALSE,
......@@ -113,6 +118,10 @@ class Api implements OutputInterface, API_ProviderInterface, EventSubscriberInte
}
foreach($dataProcessor->getFilterHandlers() as $filterHandler) {
$fieldSpec = $filterHandler->getFieldSpecification();
$type = \CRM_Utils_Type::T_STRING;
if (isset($types[$fieldSpec->type])) {
$type = $types[$fieldSpec->type];
}
if (!$fieldSpec) {
continue;
}
......@@ -120,7 +129,7 @@ class Api implements OutputInterface, API_ProviderInterface, EventSubscriberInte
'name' => $fieldSpec->alias,
'title' => $fieldSpec->title,
'description' => '',
'type' => $fieldSpec->type,
'type' => $type,
'api.required' => $filterHandler->isRequired(),
'api.aliases' => [],
'api.filter' => TRUE,
......@@ -279,6 +288,7 @@ class Api implements OutputInterface, API_ProviderInterface, EventSubscriberInte
$actions[] = $dao->api_action;
$actions[] = $dao->api_count_action;
}
$actions[] = 'getfields';
return $actions;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment