class PrivateMessageActivityContext in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 8 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 8.2 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 8.3 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 8.4 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 8.5 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 8.7 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 8.8 modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 10.3.x modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 10.0.x modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 10.1.x modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- 10.2.x modules/social_features/social_private_message/src/Plugin/ActivityContext/PrivateMessageActivityContext.php \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
Provides a 'PrivateMessageActivityContext' activity context.
Plugin annotation
@ActivityContext(
id = "private_message_activity_context",
label = @Translation("Private message activity context"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
- class \Drupal\social_private_message\Plugin\ActivityContext\PrivateMessageActivityContext
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
Expanded class hierarchy of PrivateMessageActivityContext
File
- modules/
social_features/ social_private_message/ src/ Plugin/ ActivityContext/ PrivateMessageActivityContext.php, line 18
Namespace
Drupal\social_private_message\Plugin\ActivityContextView source
class PrivateMessageActivityContext extends ActivityContextBase {
/**
* {@inheritdoc}
*/
public function getRecipients(array $data, $last_uid, $limit) {
$recipients = [];
// We only know the context if there is a related object.
if (isset($data['related_object']) && !empty($data['related_object'])) {
$related_object = $data['related_object'][0];
if ($related_object['target_type'] == 'private_message') {
$related_object = $data['related_object'][0];
if ($related_object['target_type'] === 'private_message') {
$private_message = PrivateMessage::load($related_object['target_id']);
// Must be a Private Message.
if ($private_message instanceof PrivateMessage) {
$pmService = \Drupal::service('private_message.service');
// Get the thread of this message.
$thread = $pmService
->getThreadFromMessage($private_message);
if ($thread instanceof PrivateMessageThreadInterface) {
// Get all members of this thread.
/** @var \Drupal\private_message\Entity\PrivateMessageThreadInterface $members */
$members = $thread
->getMembers();
// Loop over all PMT participants.
foreach ($members as $member) {
if ($member instanceof User) {
// Filter out the author of this message.
if ($member
->id() == $data['actor']) {
continue;
}
// Create the recipients array.
$recipients[] = [
'target_type' => 'user',
'target_id' => $member
->id(),
];
}
}
}
}
}
}
}
return $recipients;
}
/**
* Check if it's valid.
*/
public function isValidEntity($entity) {
if ($entity
->getEntityTypeId() === 'private_message') {
return TRUE;
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActivityContextBase:: |
private | property | Entity query. | |
ActivityContextBase:: |
protected | property | Entity type manager. | |
ActivityContextBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
ActivityContextBase:: |
public | function | Returns recipients from post. | |
ActivityContextBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
1 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PrivateMessageActivityContext:: |
public | function |
Returns a batched list of recipients for this context. Overrides ActivityContextBase:: |
|
PrivateMessageActivityContext:: |
public | function |
Check if it's valid. Overrides ActivityContextBase:: |