From 12d31e300f6109206d7cf377a8bb3d967501c4e6 Mon Sep 17 00:00:00 2001 From: Marc Michalsky forumZFD Date: Tue, 29 Sep 2020 08:58:53 +0200 Subject: [PATCH] format & comment code --- .../Upgrader/models/CustomField.php | 29 ++++++++++++++++--- api/v3/TwingleSync/models/TwingleProject.php | 14 +++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CRM/TwingleCampaign/Upgrader/models/CustomField.php b/CRM/TwingleCampaign/Upgrader/models/CustomField.php index 9053ab3..8871b52 100644 --- a/CRM/TwingleCampaign/Upgrader/models/CustomField.php +++ b/CRM/TwingleCampaign/Upgrader/models/CustomField.php @@ -8,20 +8,35 @@ use CRM_TwingleCampaign_ExtensionUtil as E; class CustomField { private $id; + private $custom_group_id; + private $label; + private $name; + private $is_required; + private $is_searchable; + private $data_type; + private $html_type; + private $option_values; + private $text_length; + private $is_active; + private $is_view; + private $weight; + private $help_post; + private $default_value; + private $result; /** @@ -50,12 +65,11 @@ class CustomField { 'get', [ 'sequential' => 1, - 'name' => $this->getName() + 'name' => $this->getName(), ] ); - if ($field['count'] == 0) - { + if ($field['count'] == 0) { $this->result = civicrm_api3( 'CustomField', 'create', @@ -101,6 +115,8 @@ class CustomField { } /** + * Alter a custom field + * * @param $values * * @return bool @@ -122,7 +138,7 @@ class CustomField { /** * @param $name * - * @return \CRM\TwingleCampaign\Models\CustomField + * @return array|\CRM\TwingleCampaign\Models\CustomField * @throws \CiviCRM_API3_Exception */ public static function fetch($name = NULL) { @@ -163,6 +179,11 @@ class CustomField { } } + /** + * Delete a custom field + * + * @throws \CiviCRM_API3_Exception + */ public function delete() { $this->result = civicrm_api3( 'CustomField', diff --git a/api/v3/TwingleSync/models/TwingleProject.php b/api/v3/TwingleSync/models/TwingleProject.php index c49f876..7815368 100644 --- a/api/v3/TwingleSync/models/TwingleProject.php +++ b/api/v3/TwingleSync/models/TwingleProject.php @@ -35,7 +35,9 @@ class TwingleProject { */ public function __construct(array $values) { - $this->timestamp = $values['last_update']; + $this->values = $values; + + $this->project_id = $values['project_id']; // Format data types of the values for import into CiviCRM $this->formatForImport($values); @@ -46,7 +48,7 @@ class TwingleProject { } /** - * Get all related custom fields as CustomField objects in an static array. + * Get custom field mapping. * This function will be fully executed only once, when the TwingleProject * class gets instantiated for the first time. * @@ -142,12 +144,12 @@ class TwingleProject { // Change timestamp into DateTime string if (!empty($values['last_update'])) { - $date = DateTime::createFromFormat('U', $values['last_update'] ); + $date = DateTime::createFromFormat('U', $values['last_update']); $values['last_update'] = $date->format('Y-m-d H:i:s'); } // Change event type empty string into 'default' - if ($values['type'] == ''){ + if ($values['type'] == '') { $values['type'] = 'default'; } } @@ -161,12 +163,12 @@ class TwingleProject { // Change DateTime string into timestamp if (!empty($values['last_update'])) { - $date = DateTime::createFromFormat('Y-m-d H:i:s', $values['last_update'] ); + $date = DateTime::createFromFormat('Y-m-d H:i:s', $values['last_update']); $values['last_update'] = $date->getTimestamp(); } // Change event type 'default' into empty string - if ($values['type'] == 'default'){ + if ($values['type'] == 'default') { $values['type'] = ''; } }