set object values via update() method to filter them

This commit is contained in:
Marc Michalsky forumZFD 2020-12-15 14:50:59 +01:00
parent a9ebd8c514
commit b210f42b8f
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -43,16 +43,6 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
// Set campaign values // Set campaign values
$this->update($campaign); $this->update($campaign);
// Filter project values
$filter = Cache::getInstance()->getTemplates()[$this->className];
foreach ($campaign as $key => $value) {
if (in_array($key, $filter)) {
$this->values[$key] = $value;
}
}
} }
/** /**
@ -118,7 +108,15 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
*/ */
public function update(array $values) { public function update(array $values) {
// Update campaign values // Update campaign values
$this->values = array_merge($this->values, $values); $filter = Cache::getInstance()->getTemplates()[$this->className];
foreach ($values as $key => $value) {
if ($this->className == "TwingleProject" && $key == 'project_id') {
$this->values['id'] = $value;
}
else if (in_array($key, $filter)) {
$this->values[$key] = $value;
}
}
} }