*/
use Civi\ActionSchedule\Event\MappingRegisterEvent;
+use Civi\ActionSchedule\MappingBase;
use Civi\Core\HookInterface;
/**
*/
public static function getEntityValueOptions(string $fieldName, array $params): array {
$values = self::fillValues($params['values'], ['mapping_id']);
- if (!$values['mapping_id']) {
- return [];
- }
- return self::getMapping($values['mapping_id'])->getValueLabels();
+ $mapping = self::getMapping($values['mapping_id']);
+ return $mapping ? $mapping->getValueLabels() : [];
}
/**
*/
public static function getLimitToOptions(string $fieldName, array $params): ?array {
$values = self::fillValues($params['values'], ['mapping_id']);
- if (!$values['mapping_id']) {
- return Civi\ActionSchedule\MappingBase::getLimitToOptions();
- }
- return self::getMapping($values['mapping_id'])::getLimitToOptions();
+ $mapping = self::getMapping($values['mapping_id']);
+ return $mapping ? $mapping::getLimitToOptions() : MappingBase::getLimitToOptions();
}
/**
*/
public static function getRecipientOptions(string $fieldName, array $params): ?array {
$values = self::fillValues($params['values'], ['mapping_id']);
- if (!$values['mapping_id']) {
- return Civi\ActionSchedule\MappingBase::getRecipientTypes();
- }
- return self::getMapping($values['mapping_id'])::getRecipientTypes();
+ $mapping = self::getMapping($values['mapping_id']);
+ return $mapping ? $mapping::getRecipientTypes() : MappingBase::getRecipientTypes();
}
/**
*/
public static function getRecipientListingOptions(string $fieldName, array $params): ?array {
$values = self::fillValues($params['values'], ['mapping_id', 'recipient']);
- if (!$values['mapping_id']) {
- return [];
- }
- return self::getMapping($values['mapping_id'])->getRecipientListing($values['recipient']);
+ $mapping = self::getMapping($values['mapping_id']);
+ return $mapping ? $mapping->getRecipientListing($values['recipient']) : [];
}
/**
*/
public static function getEntityStatusOptions(string $fieldName, array $params): array {
$values = self::fillValues($params['values'], ['mapping_id', 'entity_value']);
- if (!$values['mapping_id']) {
- return [];
- }
- return self::getMapping($values['mapping_id'])->getStatusLabels($values['entity_value']);
+ $mapping = self::getMapping($values['mapping_id']);
+ return $mapping ? $mapping->getStatusLabels($values['entity_value']) : [];
}
/**
*/
public static function getActionDateOptions(string $fieldName, array $params): array {
$values = self::fillValues($params['values'], ['mapping_id', 'entity_value']);
- if (!$values['mapping_id']) {
- return [];
- }
- return self::getMapping($values['mapping_id'])->getDateFields($values['entity_value']);
+ $mapping = self::getMapping($values['mapping_id']);
+ return $mapping ? $mapping->getDateFields($values['entity_value']) : [];
}
/**