remove $origin parameter

it isn't necessary anymore because I use my own APIs to get the data always in the Twingle format
This commit is contained in:
Marc Michalsky forumZFD 2020-12-15 14:49:31 +01:00
parent f10b920465
commit a9ebd8c514
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
4 changed files with 11 additions and 40 deletions

View file

@ -14,10 +14,6 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
// OUT means: coming from the CiviCRM database // OUT means: coming from the CiviCRM database
public const OUT = 'OUT'; public const OUT = 'OUT';
public const CIVICRM = 'CIVICRM';
public const TWINGLE = 'TWINGLE';
protected $className; protected $className;
protected $id; protected $id;
@ -35,31 +31,18 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
* @param array $campaign * @param array $campaign
* Result array of Twingle API call * Result array of Twingle API call
* *
* @param string $origin
* Origin of the arrays. It can be one of two constants: * Origin of the arrays. It can be one of two constants:
* Campaign::TWINGLE|CIVICRM * Campaign::TWINGLE|CIVICRM
* *
* @throws Exception * @throws Exception
*/ */
protected function __construct(array $campaign, string $origin) { protected function __construct(array $campaign) {
$tmpClassName = explode('_', get_class($this)); $tmpClassName = explode('_', get_class($this));
$this->className = array_pop($tmpClassName); $this->className = array_pop($tmpClassName);
// If values come from CiviCRM Campaign API // Set campaign values
if ($origin == self::CIVICRM) { $this->update($campaign);
// Set id (campaign id) attribute
$this->id = $campaign['id'];
// Translate custom field names into Twingle field names
$this->translateCustomFields($campaign, self::OUT);
// Translate keys and values
//self::formatValues($campaign, self::OUT);
self::translateKeys($campaign, self::OUT);
}
// Filter project values // Filter project values
$filter = Cache::getInstance()->getTemplates()[$this->className]; $filter = Cache::getInstance()->getTemplates()[$this->className];

View file

@ -15,14 +15,10 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
* Result array of Twingle API call to * Result array of Twingle API call to
* https://project.twingle.de/api/$project_id/event * https://project.twingle.de/api/$project_id/event
* *
* @param string $origin
* Origin of the arrays. It can be one of two constants:
* TwingleEvent::TWINGLE|CIVICRM
*
* @throws Exception * @throws Exception
*/ */
protected function __construct(array $event, string $origin) { protected function __construct(array $event) {
parent::__construct($event, $origin); parent::__construct($event);
$this->prefix = 'twingle_event_'; $this->prefix = 'twingle_event_';
$this->values['campaign_type_id'] = 'twingle_event'; $this->values['campaign_type_id'] = 'twingle_event';
@ -60,10 +56,7 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
// Instantiate TwingleEvent // Instantiate TwingleEvent
try { try {
$event = new self( $event = new self($values);
$values,
self::TWINGLE
);
} catch (Exception $e) { } catch (Exception $e) {
$errorMessage = $e->getMessage(); $errorMessage = $e->getMessage();

View file

@ -13,15 +13,12 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
* Result array of Twingle API call to * Result array of Twingle API call to
* https://project.twingle.de/api/by-organisation/$organisation_id * https://project.twingle.de/api/by-organisation/$organisation_id
* *
* @param string $origin
* Origin of the arrays. It can be one of two constants:
* TwingleProject::TWINGLE|CIVICRM
* @param int|null $id * @param int|null $id
* *
* @throws \Exception * @throws \Exception
*/ */
function __construct(array $project, string $origin, int $id = NULL) { function __construct(array $project, int $id = NULL) {
parent::__construct($project, $origin); parent::__construct($project);
$this->id = $id; $this->id = $id;
$this->prefix = 'twingle_project_'; $this->prefix = 'twingle_project_';
@ -58,10 +55,7 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
// Instantiate TwingleProject // Instantiate TwingleProject
try { try {
$project = new self( $project = new self($values);
$values,
self::TWINGLE
);
} catch (Exception $e) { } catch (Exception $e) {
$errorMessage = $e->getMessage(); $errorMessage = $e->getMessage();

View file

@ -97,10 +97,11 @@ function civicrm_api3_twingle_sync_Sync($params) {
$id = $project_from_civicrm['id']; $id = $project_from_civicrm['id'];
unset($project_from_civicrm['id']); unset($project_from_civicrm['id']);
$project_from_civicrm['name'] = $project_from_civicrm['title']; $project_from_civicrm['name'] = $project_from_civicrm['title'];
$project = new TwingleProject($project_from_civicrm, TwingleProject::TWINGLE, $id); $project = new TwingleProject($project_from_civicrm, $id);
$values = $twingleApi->pushProject($project); $values = $twingleApi->pushProject($project);
$project->update($values); $project->update($values);
$result_values['sync']['projects'][$i++] = $project->create(); $result_values['sync']['projects'][$i++] = $project->create();
} }
} }