Before: function getEntity() actually returns the name of the table, not the entity
After: function getEntityTable() returns table name and getEntityName() returns entity name
* @inheritDoc
*/
public function alterActionScheduleQuery(MailingQueryEvent $e): void {
- if ($e->mapping->getEntity() !== $this->getExtendableTableName()) {
+ if ($e->mapping->getEntityTable() !== $this->getExtendableTableName()) {
return;
}
/**
* @return string
*/
- public function getEntity() {
+ public function getEntityTable(): string {
return 'civicrm_contribution';
}
+ public function getEntityName(): string {
+ return 'Contribution';
+ }
+
/**
* Get a printable label for this mapping type.
*
/**
* @return string
*/
- public function getEntity() {
+ public function getEntityTable(): string {
return 'civicrm_contribution';
}
+ /**
+ * @return string
+ */
+ public function getEntityName(): string {
+ return 'Contribution';
+ }
+
/**
* Get a printable label for this mapping type.
*
protected static function createMailingActivity($tokenRow, $mapping, $contactID, $entityID, $caseID) {
$session = CRM_Core_Session::singleton();
- if ($mapping->getEntity() == 'civicrm_membership') {
+ if ($mapping->getEntityTable() == 'civicrm_membership') {
// @todo - not required with api
$activityTypeID
= CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Membership Renewal Reminder');
'casActionScheduleId' => $actionSchedule->id,
'casMailingJoinType' => ($actionSchedule->limit_to == 0) ? 'LEFT JOIN' : 'INNER JOIN',
'casMappingId' => $mapping->getId(),
- 'casMappingEntity' => $mapping->getEntity(),
+ 'casMappingEntity' => $mapping->getEntityTable(),
'casEntityJoinExpr' => 'e.id = IF(reminder.entity_table = "civicrm_contact", reminder.contact_id, reminder.entity_id)',
]);
return (!empty($processor->context['actionMapping'])
// This makes the 'schema context compulsory - which feels accidental
// since recent discu
- && $processor->context['actionMapping']->getEntity()) || in_array($this->getEntityIDField(), $processor->context['schema']);
+ && $processor->context['actionMapping']->getEntityTable()) || in_array($this->getEntityIDField(), $processor->context['schema']);
}
/**
* @param \Civi\ActionSchedule\Event\MailingQueryEvent $e
*/
public function alterActionScheduleQuery(MailingQueryEvent $e): void {
- if ($e->mapping->getEntity() !== $this->getExtendableTableName()) {
+ if ($e->mapping->getEntityTable() !== $this->getExtendableTableName()) {
return;
}
$e->query->select('e.id AS tokenContext_' . $this->getEntityIDField());
public function checkActive(TokenProcessor $processor) {
return in_array($this->getEntityContextSchema(), $processor->context['schema']) ||
(!empty($processor->context['actionMapping'])
- && $processor->context['actionMapping']->getEntity() === $this->getEntityTableName());
+ && $processor->context['actionMapping']->getEntityTable() === $this->getEntityTableName());
}
/**
public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQueryEvent $e): void {
// When targeting `civicrm_participant` records, we enable both `{participant.*}` (per usual) and the related `{event.*}`.
parent::alterActionScheduleQuery($e);
- if ($e->mapping->getEntity() === $this->getExtendableTableName()) {
+ if ($e->mapping->getEntityTable() === $this->getExtendableTableName()) {
$e->query->select('e.event_id AS tokenContext_eventId');
}
}
/**
* @return string
*/
- public function getEntity() {
+ public function getEntityTable(): string {
return $this->entity;
}
+ public function getEntityName(): string {
+ return \CRM_Core_DAO_AllCoreTables::getEntityNameForTable($this->getEntityTable());
+ }
+
/**
* Get a printable label for this mapping type.
*
public function getId();
/**
+ * Name of the table belonging to the main entity e.g. `civicrm_activity`
* @return string
*/
- public function getEntity();
+ public function getEntityTable(): string;
+
+ /**
+ * Main entity name e.g. `Activity`
+ * @return string
+ */
+ public function getEntityName(): string;
/**
* Get a printable label for this mapping type.
->merge($this->prepareAddlFilter('c.id'))
->where("c.id NOT IN (
SELECT rem.contact_id
- FROM civicrm_action_log rem INNER JOIN {$this->mapping->getEntity()} e ON rem.entity_id = e.id
+ FROM civicrm_action_log rem INNER JOIN {$this->mapping->getEntityTable()} e ON rem.entity_id = e.id
WHERE rem.action_schedule_id = {$this->actionSchedule->id}
- AND rem.entity_table = '{$this->mapping->getEntity()}'
+ AND rem.entity_table = '{$this->mapping->getEntityTable()}'
)")
// Where does e.id come from here? ^^^
->groupBy("c.id")
$defaultParams = [
'casActionScheduleId' => $this->actionSchedule->id,
'casMappingId' => $this->mapping->getId(),
- 'casMappingEntity' => $this->mapping->getEntity(),
+ 'casMappingEntity' => $this->mapping->getEntityTable(),
'casNow' => $this->now,
];
$date = $operator . "(!casDateField, INTERVAL {$actionSchedule->start_action_offset} {$actionSchedule->start_action_unit})";
$startDateClauses[] = "'!casNow' >= {$date}";
// This is weird. Waddupwidat?
- if ($this->mapping->getEntity() == 'civicrm_participant') {
+ if ($this->mapping->getEntityTable() == 'civicrm_participant') {
$startDateClauses[] = $operator . "(!casNow, INTERVAL 1 DAY ) {$op} " . '!casDateField';
}
else {
switch ($for) {
case 'rel':
$contactIdField = $query['casContactIdField'];
- $entityName = $this->mapping->getEntity();
+ $entityName = $this->mapping->getEntityTable();
$entityIdField = $query['casEntityIdField'];
break;