Commit c8566f46 authored by Johan Vervloet's avatar Johan Vervloet
Browse files

Return empty array if no existing entity is found.

parent c2527c80
......@@ -24,10 +24,11 @@ abstract class CRM_Civiconfig_Entity {
/**
* Function to find an existing entity based on the entity's parameters.
*
* If no existing entity is found, an empty array is returned.
* This default implementation searches on the name, but you can override it.
*
* @param array $params
* @return array|bool
* @return array
* @access public
* @static
*/
......@@ -35,7 +36,7 @@ abstract class CRM_Civiconfig_Entity {
try {
return civicrm_api3($this->entity, 'Getsingle', array('name'=> $params['name']));
} catch (\CiviCRM_API3_Exception $ex) {
return FALSE;
return [];
}
}
......
......@@ -70,15 +70,16 @@ class CRM_Civiconfig_Entity_CustomField extends CRM_Civiconfig_Entity {
/**
* Method to get the existing custom field
* If no existing entity is found, an empty array is returned.
*
* @param array $params
* @return array|bool
* @return array
*/
public function getExisting(array $params) {
try {
return civicrm_api3('CustomField', 'Getsingle', array('name' => $params['name'], 'custom_group_id' => $params['custom_group_id']));
} catch (\CiviCRM_API3_Exception $ex) {
return FALSE;
return [];
}
}
......
......@@ -73,10 +73,11 @@ class CRM_Civiconfig_Entity_Group extends CRM_Civiconfig_Entity {
/**
* Function to find an existing group based on the parameters.
*
* If no existing entity is found, an empty array is returned.
* Overridden so that it also returns the saved search - if any.
*
* @param array $params
* @return array|bool
* @return array
* @access public
* @static
*/
......@@ -87,7 +88,7 @@ class CRM_Civiconfig_Entity_Group extends CRM_Civiconfig_Entity {
'api.SavedSearch.get' => array('id' => '$value.saved_search_id'),
));
} catch (\CiviCRM_API3_Exception $ex) {
return FALSE;
return [];
}
}
......
......@@ -29,10 +29,11 @@ class CRM_Civiconfig_Entity_RelationshipType extends CRM_Civiconfig_Entity {
/**
* Function to find an existing entity based on the entity's parameters.
*
* If no existing entity is found, an empty array is returned.
* This default implementation searches on the name, but you can override it.
*
* @param array $params
* @return array|bool
* @return array
* @access public
* @static
*/
......@@ -40,7 +41,7 @@ class CRM_Civiconfig_Entity_RelationshipType extends CRM_Civiconfig_Entity {
try {
return civicrm_api3($this->entity, 'Getsingle', array('name_a_b'=> $params['name_a_b']));
} catch (\CiviCRM_API3_Exception $ex) {
return FALSE;
return [];
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment