format & comment code

This commit is contained in:
Marc Michalsky forumZFD 2020-09-29 08:58:53 +02:00
parent e923ba91dc
commit 12d31e300f
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
2 changed files with 33 additions and 10 deletions

View file

@ -8,20 +8,35 @@ use CRM_TwingleCampaign_ExtensionUtil as E;
class CustomField { class CustomField {
private $id; private $id;
private $custom_group_id; private $custom_group_id;
private $label; private $label;
private $name; private $name;
private $is_required; private $is_required;
private $is_searchable; private $is_searchable;
private $data_type; private $data_type;
private $html_type; private $html_type;
private $option_values; private $option_values;
private $text_length; private $text_length;
private $is_active; private $is_active;
private $is_view; private $is_view;
private $weight; private $weight;
private $help_post; private $help_post;
private $default_value; private $default_value;
private $result; private $result;
/** /**
@ -50,12 +65,11 @@ class CustomField {
'get', 'get',
[ [
'sequential' => 1, 'sequential' => 1,
'name' => $this->getName() 'name' => $this->getName(),
] ]
); );
if ($field['count'] == 0) if ($field['count'] == 0) {
{
$this->result = civicrm_api3( $this->result = civicrm_api3(
'CustomField', 'CustomField',
'create', 'create',
@ -101,6 +115,8 @@ class CustomField {
} }
/** /**
* Alter a custom field
*
* @param $values * @param $values
* *
* @return bool * @return bool
@ -122,7 +138,7 @@ class CustomField {
/** /**
* @param $name * @param $name
* *
* @return \CRM\TwingleCampaign\Models\CustomField * @return array|\CRM\TwingleCampaign\Models\CustomField
* @throws \CiviCRM_API3_Exception * @throws \CiviCRM_API3_Exception
*/ */
public static function fetch($name = NULL) { public static function fetch($name = NULL) {
@ -163,6 +179,11 @@ class CustomField {
} }
} }
/**
* Delete a custom field
*
* @throws \CiviCRM_API3_Exception
*/
public function delete() { public function delete() {
$this->result = civicrm_api3( $this->result = civicrm_api3(
'CustomField', 'CustomField',

View file

@ -35,7 +35,9 @@ class TwingleProject {
*/ */
public function __construct(array $values) { 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 // Format data types of the values for import into CiviCRM
$this->formatForImport($values); $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 * This function will be fully executed only once, when the TwingleProject
* class gets instantiated for the first time. * class gets instantiated for the first time.
* *