code cleanup
This commit is contained in:
parent
a53b61775a
commit
86639cfe42
5 changed files with 23 additions and 23 deletions
|
@ -49,13 +49,13 @@ class CRM_TwingleCampaign_BAO_CampaignType {
|
||||||
$this->value = array_column($this->results['values'], 'value')[0];
|
$this->value = array_column($this->results['values'], 'value')[0];
|
||||||
|
|
||||||
if ($this->results['is_error'] == 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
|
label: $this->label
|
||||||
name: $this->name"
|
name: $this->name"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
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']");
|
for \"$this->label\": $this->results['error_message']");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class CRM_TwingleCampaign_BAO_CampaignType {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->results['is_error'] == 0) {
|
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
|
label: $this->label\n
|
||||||
name: $this->name"
|
name: $this->name"
|
||||||
);
|
);
|
||||||
|
@ -146,12 +146,12 @@ class CRM_TwingleCampaign_BAO_CampaignType {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($this->label) {
|
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']"
|
\"$this->label\": $this->results['error_message']"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
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']");
|
$this->results['error_message']");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
||||||
|
|
||||||
// Log field creation
|
// Log field creation
|
||||||
if ($this->result['is_error'] == 0) {
|
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
|
label: $this->label
|
||||||
name: $this->name
|
name: $this->name
|
||||||
id: $this->id
|
id: $this->id
|
||||||
|
@ -96,14 +96,14 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
||||||
// If the field could not get created: log error
|
// If the field could not get created: log error
|
||||||
else {
|
else {
|
||||||
if ($this->label && $this->custom_group_id) {
|
if ($this->label && $this->custom_group_id) {
|
||||||
\Civi::log()
|
Civi::log()
|
||||||
->error("Twingle Extension could not create new custom field
|
->error("Twingle Extension could not create new custom field
|
||||||
\"$this->label\" for group \"$this->custom_group_id\":
|
\"$this->label\" for group \"$this->custom_group_id\":
|
||||||
$this->result['error_message']");
|
$this->result['error_message']");
|
||||||
}
|
}
|
||||||
// If there is not enough information: log simple error message
|
// If there is not enough information: log simple error message
|
||||||
else {
|
else {
|
||||||
\Civi::log()
|
Civi::log()
|
||||||
->error("Twingle Extension could not create new custom field:
|
->error("Twingle Extension could not create new custom field:
|
||||||
$this->result['error_message']");
|
$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
|
// Log an error and throw an exception if the file cannot get read
|
||||||
if (!$campaign_info) {
|
if (!$campaign_info) {
|
||||||
\Civi::log()->error("Could not read json file");
|
Civi::log()->error("Could not read json file");
|
||||||
throw new \Exception('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
|
// 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
|
// Check if custom field was deleted successfully
|
||||||
if ($this->result['is_error'] == 0) {
|
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
|
label: $this->label
|
||||||
name: $this->name
|
name: $this->name
|
||||||
id: $this->id
|
id: $this->id
|
||||||
|
@ -231,13 +231,13 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
||||||
// ... else: log error
|
// ... else: log error
|
||||||
else {
|
else {
|
||||||
if ($this->label && $this->custom_group_id) {
|
if ($this->label && $this->custom_group_id) {
|
||||||
\Civi::log()
|
Civi::log()
|
||||||
->error("TwingleCampaign Extension could not delete custom field
|
->error("TwingleCampaign Extension could not delete custom field
|
||||||
\"$this->label\" for group \"$this->custom_group_id\":
|
\"$this->label\" for group \"$this->custom_group_id\":
|
||||||
$this->result['error_message']");
|
$this->result['error_message']");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
\Civi::log()
|
Civi::log()
|
||||||
->error("TwingleCampaign Extension could not delete custom field:
|
->error("TwingleCampaign Extension could not delete custom field:
|
||||||
$this->result['error_message']");
|
$this->result['error_message']");
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class CRM_TwingleCampaign_BAO_CustomGroup {
|
||||||
$this->id = $this->results['id'];
|
$this->id = $this->results['id'];
|
||||||
|
|
||||||
if ($this->results['is_error'] == 0) {
|
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
|
title: $this->title
|
||||||
name: $this->name
|
name: $this->name
|
||||||
extends: $this->extends
|
extends: $this->extends
|
||||||
|
@ -54,12 +54,12 @@ class CRM_TwingleCampaign_BAO_CustomGroup {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($this->title) {
|
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']"
|
for \"$this->title\": $this->results['error_message']"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
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']");
|
custom group: $this->results['error_message']");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ class CRM_TwingleCampaign_BAO_CustomGroup {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->results['is_error'] == 0) {
|
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
|
title: $this->title
|
||||||
name: $this->name
|
name: $this->name
|
||||||
extends: $this->extends
|
extends: $this->extends
|
||||||
|
@ -142,12 +142,12 @@ class CRM_TwingleCampaign_BAO_CustomGroup {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($this->title) {
|
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']"
|
\"$this->title\": $this->results['error_message']"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
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']");
|
$this->results['error_message']");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
|
||||||
protected function __construct(array $event, string $origin) {
|
protected function __construct(array $event, string $origin) {
|
||||||
parent::__construct($event, $origin);
|
parent::__construct($event, $origin);
|
||||||
|
|
||||||
$this->className = (new \ReflectionClass($this))->getShortName();
|
$this->className = (new ReflectionClass($this))->getShortName();
|
||||||
$this->prefix = 'twingle_event_';
|
$this->prefix = 'twingle_event_';
|
||||||
$this->values['campaign_type_id'] = 'twingle_event';
|
$this->values['campaign_type_id'] = 'twingle_event';
|
||||||
$this->id_custom_field = Cache::getInstance()
|
$this->id_custom_field = Cache::getInstance()
|
||||||
|
@ -369,7 +369,7 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
|
||||||
return (int) $contact['id'];
|
return (int) $contact['id'];
|
||||||
} catch (CiviCRM_API3_Exception $e) {
|
} catch (CiviCRM_API3_Exception $e) {
|
||||||
$errorMessage = $e->getMessage();
|
$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");
|
$names $lastname $email./nError Message: $errorMessage");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
|
||||||
protected function __construct(array $project, string $origin) {
|
protected function __construct(array $project, string $origin) {
|
||||||
parent::__construct($project, $origin);
|
parent::__construct($project, $origin);
|
||||||
|
|
||||||
$this->className = (new \ReflectionClass($this))->getShortName();
|
$this->className = (new ReflectionClass($this))->getShortName();
|
||||||
$this->prefix = 'twingle_project_';
|
$this->prefix = 'twingle_project_';
|
||||||
$this->values['campaign_type_id'] = 'twingle_project';
|
$this->values['campaign_type_id'] = 'twingle_project';
|
||||||
$this->id_custom_field = Cache::getInstance()
|
$this->id_custom_field = Cache::getInstance()
|
||||||
|
@ -230,7 +230,7 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
|
||||||
*/
|
*/
|
||||||
public function create(bool $is_test = FALSE) {
|
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) {
|
if (!$is_test) {
|
||||||
|
|
||||||
// Prepare project values for import into database
|
// Prepare project values for import into database
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue