do not fetch TwingleCampaign in _construct()

This commit is contained in:
Marc Michalsky forumZFD 2021-02-11 18:37:09 +01:00
parent dc2c26abb4
commit 154f9d2d34
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -24,25 +24,23 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
* ## TwingleCampaign constructor
*
* @param array|null $values
* @param int|null $id
*
* @throws CiviCRM_API3_Exception
* @throws \CiviCRM_API3_Exception
*/
public function __construct(array $values = NULL) {
public function __construct(array $values, int $id = NULL) {
$this->prefix = 'twingle_campaign_';
$this->id = $values['id'] ?? NULL;
$this->id = $id ?? NULL;
$this->values['campaign_type_id'] = 'twingle_campaign';
if ($this->id) {
$this->fetch();
if ($values) {
$this->update($values);
}
$this->update($values);
$this->getParentProject();
$this->createCid();
$this->createUrl();
}
elseif ($values) {
else {
$this->update($values);
}
}
@ -83,8 +81,8 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
* @throws CiviCRM_API3_Exception
*/
private function fetch() {
$this->values = civicrm_api3('Campaign', 'getsingle',
['id' => $this->id]);
$this->values = civicrm_api3('TwingleCampaign', 'getsingle',
['id' => $this->id])['values'];
}