Merge pull request #18916 from colemanw/crudLink
[civicrm-core.git] / CRM / Case / Form / ActivityToCase.php
index 513b9c40c1fa6c2a101e12538d9e7cfc0b50315f..e591c8405afaa1643e9115c4d6e9120499013c79 100644 (file)
@@ -22,11 +22,13 @@ class CRM_Case_Form_ActivityToCase extends CRM_Core_Form {
 
   /**
    * Build all the data structures needed to build the form.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function preProcess() {
     $this->_activityId = CRM_Utils_Request::retrieve('activityId', 'Positive');
     if (!$this->_activityId) {
-      CRM_Core_Error::fatal('required activity id is missing.');
+      throw new CRM_Core_Exception('required activity id is missing.');
     }
 
     $this->_currentCaseId = CRM_Utils_Request::retrieve('caseId', 'Positive');
@@ -46,18 +48,19 @@ class CRM_Case_Form_ActivityToCase extends CRM_Core_Form {
   }
 
   /**
-   * Set default values for the form. For edit/view mode
-   * the default values are retrieved from the database
-   *
+   * Set default values for the form. For edit/view mode.
    *
    * @return array
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public function setDefaultValues() {
     $defaults = [];
     $params = ['id' => $this->_activityId];
 
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
-    $defaults['file_on_case_activity_subject'] = $defaults['subject'];
+    $defaults['file_on_case_activity_subject'] = $defaults['subject'] ?? '';
     $defaults['file_on_case_target_contact_id'] = $defaults['target_contact'];
 
     // If this contact has an open case, supply it as a default