code cleanup

This commit is contained in:
Marc Michalsky forumZFD 2020-12-08 12:58:53 +01:00
parent a53b61775a
commit 86639cfe42
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
5 changed files with 23 additions and 23 deletions

View file

@ -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']");
}
}

View file

@ -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']");
}

View file

@ -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']");
}
}

View file

@ -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;
}

View file

@ -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