*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
- CRM_Contact_BAO_RelationshipType::del($this->_id);
+ CRM_Contact_BAO_RelationshipType::deleteRecord(['id' => $this->_id]);
CRM_Core_Session::setStatus(ts('Selected Relationship type has been deleted.'), ts('Record Deleted'), 'success');
}
else {
* @return mixed
*/
public static function del($relationshipTypeId) {
- // make sure relationshipTypeId is an integer
- // @todo review this as most delete functions rely on the api & form layer for this
- // or do a find first & throw error if no find
- if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
- throw new CRM_Core_Exception(ts('Invalid relationship type'));
- }
+ CRM_Core_Error::deprecatedFunctionWarning('deleteRecord');
+
return static::deleteRecord(['id' => $relationshipTypeId]);
}
* Relationship ID
*/
private function deleteAction($id) {
- CRM_Contact_BAO_Relationship::del($id);
+ CRM_Contact_BAO_Relationship::deleteRecord(['id' => $id]);
CRM_Core_Session::setStatus(ts('Selected relationship has been deleted successfully.'), ts('Record Deleted'), 'success');
// reload all blocks to reflect this change on the user interface.
}
// delete relationship
- CRM_Contact_BAO_Relationship::del($this->getEntityId());
+ CRM_Contact_BAO_Relationship::deleteRecord(['id' => $this->getEntityId()]);
CRM_Core_Session::setStatus(ts('Selected relationship has been deleted successfully.'), ts('Record Deleted'), 'success');
CRM_Utils_System::redirect($url);
*/
public function delete() {
// calls a function to delete relationship
- CRM_Contact_BAO_Relationship::del($this->getEntityId());
+ CRM_Contact_BAO_Relationship::deleteRecord(['id' => $this->getEntityId()]);
CRM_Core_Session::setStatus(ts('Selected relationship has been deleted successfully.'), ts('Record Deleted'), 'success');
}
*
* @return array
* API Result Array
+ *
+ * @throws \CRM_Core_Exception
*/
-function civicrm_api3_relationship_delete($params) {
-
- if (!CRM_Utils_Rule::integer($params['id'])) {
- return civicrm_api3_create_error('Invalid value for relationship ID');
- }
-
- $relationBAO = new CRM_Contact_BAO_Relationship();
- $relationBAO->id = $params['id'];
- if (!$relationBAO->find(TRUE)) {
- return civicrm_api3_create_error('Relationship id is not valid');
- }
- else {
- $relationBAO->del($params['id']);
- return civicrm_api3_create_success('Deleted relationship successfully');
- }
+function civicrm_api3_relationship_delete(array $params): array {
+ return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**