From 86639cfe42c13c7ae0afe57d188f0ab3b75e8a70 Mon Sep 17 00:00:00 2001 From: Marc Michalsky forumZFD Date: Tue, 8 Dec 2020 12:58:53 +0100 Subject: [PATCH] code cleanup --- CRM/TwingleCampaign/BAO/CampaignType.php | 10 +++++----- CRM/TwingleCampaign/BAO/CustomField.php | 16 ++++++++-------- CRM/TwingleCampaign/BAO/CustomGroup.php | 12 ++++++------ CRM/TwingleCampaign/BAO/TwingleEvent.php | 4 ++-- CRM/TwingleCampaign/BAO/TwingleProject.php | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CRM/TwingleCampaign/BAO/CampaignType.php b/CRM/TwingleCampaign/BAO/CampaignType.php index 88c6c15..4403c3d 100644 --- a/CRM/TwingleCampaign/BAO/CampaignType.php +++ b/CRM/TwingleCampaign/BAO/CampaignType.php @@ -49,13 +49,13 @@ class CRM_TwingleCampaign_BAO_CampaignType { $this->value = array_column($this->results['values'], 'value')[0]; if ($this->results['is_error'] == 0) { - \Civi::log()->info("Twingle Extension has created a new campaign type. + Civi::log()->info("Twingle Extension has created a new campaign type. label: $this->label name: $this->name" ); } else { - \Civi::log()->error("Twingle Extension could not create new campaign type + Civi::log()->error("Twingle Extension could not create new campaign type for \"$this->label\": $this->results['error_message']"); } } @@ -135,7 +135,7 @@ class CRM_TwingleCampaign_BAO_CampaignType { ); if ($this->results['is_error'] == 0) { - \Civi::log()->info("TwingleCampaign Extension has deleted campaign type.\n + Civi::log()->info("TwingleCampaign Extension has deleted campaign type.\n label: $this->label\n name: $this->name" ); @@ -146,12 +146,12 @@ class CRM_TwingleCampaign_BAO_CampaignType { } else { if ($this->label) { - \Civi::log()->error("TwingleCampaign Extension could not delete campaign type + Civi::log()->error("TwingleCampaign Extension could not delete campaign type \"$this->label\": $this->results['error_message']" ); } else { - \Civi::log()->error("TwingleCampaign Extension could not delete campaign type: + Civi::log()->error("TwingleCampaign Extension could not delete campaign type: $this->results['error_message']"); } } diff --git a/CRM/TwingleCampaign/BAO/CustomField.php b/CRM/TwingleCampaign/BAO/CustomField.php index cdb7f11..c634d55 100644 --- a/CRM/TwingleCampaign/BAO/CustomField.php +++ b/CRM/TwingleCampaign/BAO/CustomField.php @@ -86,7 +86,7 @@ class CRM_TwingleCampaign_BAO_CustomField { // Log field creation if ($this->result['is_error'] == 0) { - \Civi::log()->info("Twingle Extension has created a new custom field. + Civi::log()->info("Twingle Extension has created a new custom field. label: $this->label name: $this->name id: $this->id @@ -96,14 +96,14 @@ class CRM_TwingleCampaign_BAO_CustomField { // If the field could not get created: log error else { if ($this->label && $this->custom_group_id) { - \Civi::log() + Civi::log() ->error("Twingle Extension could not create new custom field \"$this->label\" for group \"$this->custom_group_id\": $this->result['error_message']"); } // If there is not enough information: log simple error message else { - \Civi::log() + Civi::log() ->error("Twingle Extension could not create new custom field: $this->result['error_message']"); } @@ -175,8 +175,8 @@ class CRM_TwingleCampaign_BAO_CustomField { // Log an error and throw an exception if the file cannot get read if (!$campaign_info) { - \Civi::log()->error("Could not read json file"); - throw new \Exception('Could not read json file'); + Civi::log()->error("Could not read json file"); + throw new Exception('Could not read json file'); } // Recursive method call with all custom field names from the json file @@ -221,7 +221,7 @@ class CRM_TwingleCampaign_BAO_CustomField { // Check if custom field was deleted successfully if ($this->result['is_error'] == 0) { - \Civi::log()->info("Twingle Extension has deleted custom field. + Civi::log()->info("Twingle Extension has deleted custom field. label: $this->label name: $this->name id: $this->id @@ -231,13 +231,13 @@ class CRM_TwingleCampaign_BAO_CustomField { // ... else: log error else { if ($this->label && $this->custom_group_id) { - \Civi::log() + Civi::log() ->error("TwingleCampaign Extension could not delete custom field \"$this->label\" for group \"$this->custom_group_id\": $this->result['error_message']"); } else { - \Civi::log() + Civi::log() ->error("TwingleCampaign Extension could not delete custom field: $this->result['error_message']"); } diff --git a/CRM/TwingleCampaign/BAO/CustomGroup.php b/CRM/TwingleCampaign/BAO/CustomGroup.php index 2cd7cbc..805130c 100644 --- a/CRM/TwingleCampaign/BAO/CustomGroup.php +++ b/CRM/TwingleCampaign/BAO/CustomGroup.php @@ -44,7 +44,7 @@ class CRM_TwingleCampaign_BAO_CustomGroup { $this->id = $this->results['id']; if ($this->results['is_error'] == 0) { - \Civi::log()->info("TwingleCampaign Extension has created a new custom group. + Civi::log()->info("TwingleCampaign Extension has created a new custom group. title: $this->title name: $this->name extends: $this->extends @@ -54,12 +54,12 @@ class CRM_TwingleCampaign_BAO_CustomGroup { } else { if ($this->title) { - \Civi::log()->error("TwingleCampaign Extension could not create new custom group + Civi::log()->error("TwingleCampaign Extension could not create new custom group for \"$this->title\": $this->results['error_message']" ); } else { - \Civi::log()->error("TwingleCampaign Extension could not create new + Civi::log()->error("TwingleCampaign Extension could not create new custom group: $this->results['error_message']"); } } @@ -129,7 +129,7 @@ class CRM_TwingleCampaign_BAO_CustomGroup { ); if ($this->results['is_error'] == 0) { - \Civi::log()->info("TwingleCampaign Extension has deleted custom group. + Civi::log()->info("TwingleCampaign Extension has deleted custom group. title: $this->title name: $this->name extends: $this->extends @@ -142,12 +142,12 @@ class CRM_TwingleCampaign_BAO_CustomGroup { } else { if ($this->title) { - \Civi::log()->error("TwingleCampaign Extension could not delete custom group + Civi::log()->error("TwingleCampaign Extension could not delete custom group \"$this->title\": $this->results['error_message']" ); } else { - \Civi::log()->error("TwingleCampaign Extension could not delete custom group: + Civi::log()->error("TwingleCampaign Extension could not delete custom group: $this->results['error_message']"); } } diff --git a/CRM/TwingleCampaign/BAO/TwingleEvent.php b/CRM/TwingleCampaign/BAO/TwingleEvent.php index 0a8ce42..bcd43b5 100644 --- a/CRM/TwingleCampaign/BAO/TwingleEvent.php +++ b/CRM/TwingleCampaign/BAO/TwingleEvent.php @@ -23,7 +23,7 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign { protected function __construct(array $event, string $origin) { parent::__construct($event, $origin); - $this->className = (new \ReflectionClass($this))->getShortName(); + $this->className = (new ReflectionClass($this))->getShortName(); $this->prefix = 'twingle_event_'; $this->values['campaign_type_id'] = 'twingle_event'; $this->id_custom_field = Cache::getInstance() @@ -369,7 +369,7 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign { return (int) $contact['id']; } catch (CiviCRM_API3_Exception $e) { $errorMessage = $e->getMessage(); - \Civi::log()->error("TwingleCampaign extension could not match or create a contact for: + Civi::log()->error("TwingleCampaign extension could not match or create a contact for: $names $lastname $email./nError Message: $errorMessage"); return NULL; } diff --git a/CRM/TwingleCampaign/BAO/TwingleProject.php b/CRM/TwingleCampaign/BAO/TwingleProject.php index 27d9850..8ef3500 100644 --- a/CRM/TwingleCampaign/BAO/TwingleProject.php +++ b/CRM/TwingleCampaign/BAO/TwingleProject.php @@ -22,7 +22,7 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign { protected function __construct(array $project, string $origin) { parent::__construct($project, $origin); - $this->className = (new \ReflectionClass($this))->getShortName(); + $this->className = (new ReflectionClass($this))->getShortName(); $this->prefix = 'twingle_project_'; $this->values['campaign_type_id'] = 'twingle_project'; $this->id_custom_field = Cache::getInstance() @@ -230,7 +230,7 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign { */ public function create(bool $is_test = FALSE) { - // Create campaign only if it does not already exist + // Create campaign only if this is not a test if (!$is_test) { // Prepare project values for import into database