fix class name detection

This commit is contained in:
Marc Michalsky forumZFD 2020-12-10 15:26:05 +01:00
parent c79e799242
commit 905d791f1a
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
3 changed files with 7 additions and 4 deletions

View file

@ -43,7 +43,8 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
*/ */
protected function __construct(array $campaign, string $origin) { protected function __construct(array $campaign, string $origin) {
$this->className = get_class($this); $className = explode('_', get_class($this));
$this->className = array_pop($className);
// If values come from CiviCRM Campaign API // If values come from CiviCRM Campaign API
if ($origin == self::CIVICRM) { if ($origin == self::CIVICRM) {

View file

@ -23,7 +23,8 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
protected function __construct(array $event, string $origin) { protected function __construct(array $event, string $origin) {
parent::__construct($event, $origin); parent::__construct($event, $origin);
$this->className = (new ReflectionClass($this))->getShortName(); $className = explode('_', (new ReflectionClass($this))->getShortName());
$this->className = array_pop($className);;
$this->prefix = 'twingle_event_'; $this->prefix = 'twingle_event_';
$this->values['campaign_type_id'] = 'twingle_event'; $this->values['campaign_type_id'] = 'twingle_event';
$this->id_custom_field = Cache::getInstance() $this->id_custom_field = Cache::getInstance()

View file

@ -19,10 +19,11 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
* *
* @throws Exception * @throws Exception
*/ */
protected function __construct(array $project, string $origin) { function __construct(array $project, string $origin) {
parent::__construct($project, $origin); parent::__construct($project, $origin);
$this->className = (new ReflectionClass($this))->getShortName(); $className = explode('_', (new ReflectionClass($this))->getShortName());
$this->className = array_pop($className);;
$this->prefix = 'twingle_project_'; $this->prefix = 'twingle_project_';
$this->values['campaign_type_id'] = 'twingle_project'; $this->values['campaign_type_id'] = 'twingle_project';
$this->id_custom_field = Cache::getInstance() $this->id_custom_field = Cache::getInstance()