Merge pull request #17376 from artfulrobot/artfulrobot-public-status-messages
[civicrm-core.git] / api / v3 / Profile.php
index 1f12a073223bb7abac2583e88961a55dc0e5a6a4..fb0597faf556e47e0d8c7475f61cb41391a3a5bf 100644 (file)
@@ -36,7 +36,7 @@
  * @throws API_Exception
  */
 function civicrm_api3_profile_get($params) {
-  $nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE;
+  $nonStandardLegacyBehaviour = is_numeric($params['profile_id']);
   if (!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', ['contact_id' => $params['contact_id'], 'check_permissions' => 1])) {
     throw new API_Exception('permission denied');
   }
@@ -63,7 +63,7 @@ function civicrm_api3_profile_get($params) {
       NULL,
       FALSE,
       NULL,
-      empty($params['check_permissions']) ? FALSE : TRUE,
+      empty($params['check_permissions']),
       NULL,
       CRM_Core_Permission::EDIT
     );
@@ -296,7 +296,7 @@ function _civicrm_api3_profile_submit_spec(&$params, $apirequest) {
     //@todo get_options should take an array - @ the moment it is only takes 'all' - which is supported
     // by other getfields fn
     // we don't resolve state, country & county for performance reasons
-    $resolveOptions = CRM_Utils_Array::value('get_options', $apirequest['params']) == 'all' ? TRUE : FALSE;
+    $resolveOptions = ($apirequest['params']['get_options'] ?? NULL) == 'all';
     $profileID = _civicrm_api3_profile_getProfileID($apirequest['params']['profile_id']);
     $params = _civicrm_api3_buildprofile_submitfields($profileID, $resolveOptions, CRM_Utils_Array::value('cache_clear', $params));
   }
@@ -442,17 +442,17 @@ function _civicrm_api3_profile_getbillingpseudoprofile(&$params) {
 
   if (!empty($result['api.address.get.1']['count'])) {
     foreach ($addressFields as $fieldname) {
-      $values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result['api.address.get.1']['values'][0][$fieldname]) ? $result['api.address.get.1']['values'][0][$fieldname] : '';
+      $values['billing_' . $fieldname . '-' . $locationTypeID] = $result['api.address.get.1']['values'][0][$fieldname] ?? '';
     }
   }
   elseif (!empty($result['api.address.get.2']['count'])) {
     foreach ($addressFields as $fieldname) {
-      $values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result['api.address.get.2']['values'][0][$fieldname]) ? $result['api.address.get.2']['values'][0][$fieldname] : '';
+      $values['billing_' . $fieldname . '-' . $locationTypeID] = $result['api.address.get.2']['values'][0][$fieldname] ?? '';
     }
   }
   else {
     foreach ($addressFields as $fieldname) {
-      $values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result[$fieldname]) ? $result[$fieldname] : '';
+      $values['billing_' . $fieldname . '-' . $locationTypeID] = $result[$fieldname] ?? '';
     }
   }
 
@@ -515,10 +515,10 @@ function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour =
     $profileFields[$profileID][$fieldName] = array_merge([
       'api.required' => $field['is_required'],
       'title' => $field['label'],
-      'help_pre' => CRM_Utils_Array::value('help_pre', $field),
-      'help_post' => CRM_Utils_Array::value('help_post', $field),
+      'help_pre' => $field['help_pre'] ?? NULL,
+      'help_post' => $field['help_post'] ?? NULL,
       'entity' => $entity,
-      'weight' => CRM_Utils_Array::value('weight', $field),
+      'weight' => $field['weight'] ?? NULL,
     ], $aliasArray);
 
     $ufFieldTaleFieldName = $field['field_name'];