public function ActivityLoggerFactory::getMessageTypes in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8.2 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8.3 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8.4 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8.5 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8.6 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8.7 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 8.8 modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 10.3.x modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 10.0.x modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
- 10.1.x modules/custom/activity_logger/src/Service/ActivityLoggerFactory.php \Drupal\activity_logger\Service\ActivityLoggerFactory::getMessageTypes()
Get message templates for action and entity.
Parameters
string $action: Action string, e.g. 'create'.
\Drupal\Core\Entity\EntityBase $entity: Entity object.
Return value
array Array of message types.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Component\Plugin\Exception\PluginException
1 call to ActivityLoggerFactory::getMessageTypes()
- ActivityLoggerFactory::createMessages in modules/
custom/ activity_logger/ src/ Service/ ActivityLoggerFactory.php - Create message entities.
File
- modules/
custom/ activity_logger/ src/ Service/ ActivityLoggerFactory.php, line 157
Class
- ActivityLoggerFactory
- Class ActivityLoggerFactory.
Namespace
Drupal\activity_logger\ServiceCode
public function getMessageTypes($action, EntityBase $entity) {
// Init.
$messagetypes = [];
// Message type storage.
$message_storage = $this->entityTypeManager
->getStorage('message_template');
// Check all enabled messages.
foreach ($message_storage
->loadByProperties([
'status' => '1',
]) as $key => $messagetype) {
$mt_entity_bundles = $messagetype
->getThirdPartySetting('activity_logger', 'activity_bundle_entities', NULL);
$mt_action = $messagetype
->getThirdPartySetting('activity_logger', 'activity_action', NULL);
$mt_context = $messagetype
->getThirdPartySetting('activity_logger', 'activity_context', NULL);
$mt_destinations = $messagetype
->getThirdPartySetting('activity_logger', 'activity_destinations', NULL);
$mt_entity_condition = $messagetype
->getThirdPartySetting('activity_logger', 'activity_entity_condition', NULL);
if (!empty($mt_entity_condition)) {
$entity_condition_plugin = $this->activityEntityConditionManager
->createInstance($mt_entity_condition);
$entity_condition = $entity_condition_plugin
->isValidEntityCondition($entity);
}
else {
$entity_condition = TRUE;
}
$context_plugin = $this->activityContextManager
->createInstance($mt_context);
$entity_bundle_name = $entity
->getEntityTypeId() . '-' . $entity
->bundle();
if (in_array($entity_bundle_name, $mt_entity_bundles) && $context_plugin
->isValidEntity($entity) && $entity_condition && $action === $mt_action) {
$messagetypes[$key] = [
'messagetype' => $messagetype,
'bundle' => $entity_bundle_name,
'destinations' => $mt_destinations,
'context' => $mt_context,
];
}
}
// Return the message types that belong to the requested action.
return $messagetypes;
}