class FollowTagActivityContext in Open Social 10.0.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_follow_taxonomy/modules/social_follow_tag/src/Plugin/ActivityContext/FollowTagActivityContext.php \Drupal\social_follow_tag\Plugin\ActivityContext\FollowTagActivityContext
- 10.1.x modules/social_features/social_follow_taxonomy/modules/social_follow_tag/src/Plugin/ActivityContext/FollowTagActivityContext.php \Drupal\social_follow_tag\Plugin\ActivityContext\FollowTagActivityContext
- 10.2.x modules/social_features/social_follow_taxonomy/modules/social_follow_tag/src/Plugin/ActivityContext/FollowTagActivityContext.php \Drupal\social_follow_tag\Plugin\ActivityContext\FollowTagActivityContext
Provides a 'FollowTagActivityContext' activity context plugin.
Plugin annotation
@ActivityContext(
id = "follow_tag_activity_context",
label = @Translation("Following tag activity context"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
- class \Drupal\social_follow_taxonomy\Plugin\ActivityContext\FollowTaxonomyActivityContext
- class \Drupal\social_follow_tag\Plugin\ActivityContext\FollowTagActivityContext
- class \Drupal\social_follow_taxonomy\Plugin\ActivityContext\FollowTaxonomyActivityContext
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
Expanded class hierarchy of FollowTagActivityContext
File
- modules/
social_features/ social_follow_taxonomy/ modules/ social_follow_tag/ src/ Plugin/ ActivityContext/ FollowTagActivityContext.php, line 19
Namespace
Drupal\social_follow_tag\Plugin\ActivityContextView source
class FollowTagActivityContext extends FollowTaxonomyActivityContext {
/**
* Returns recipients from followed taxonomies.
*/
public function getRecipientsWhoFollowTaxonomy(array $related_entity, array $data) {
$recipients = [];
$entity = $this->entityTypeManager
->getStorage($related_entity['target_type'])
->load($related_entity['target_id']);
if (!empty($entity)) {
$tids = $this
->taxonomyTermsList($entity);
}
if (empty($tids)) {
return [];
}
$storage = $this->entityTypeManager
->getStorage('flagging');
$flaggings = $storage
->loadByProperties([
'flag_id' => 'follow_term',
'entity_type' => 'taxonomy_term',
'entity_id' => $tids,
]);
foreach ($flaggings as $flagging) {
/** @var \Drupal\flag\FlaggingInterface $flagging */
$recipient = $flagging
->getOwner();
// It could happen that a notification has been queued but the content or
// account has since been deleted. In that case we can find no recipient.
if (!$recipient instanceof UserInterface) {
continue;
}
// Do not send notification for inactive user.
if ($recipient
->isBlocked() || !$recipient
->getLastLoginTime()) {
continue;
}
$group = _social_group_get_current_group($entity);
if ($group instanceof GroupInterface) {
if (!$group
->getMember($recipient)) {
// We don't send notifications to content creator.
if ($recipient
->id() !== $entity
->getOwnerId()) {
if (!in_array($recipient
->id(), array_column($recipients, 'target_id'))) {
$recipients[] = [
'target_type' => 'user',
'target_id' => $recipient
->id(),
];
}
}
}
}
}
return $recipients;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActivityContextBase:: |
protected | property | The activity factory service. | |
ActivityContextBase:: |
private | property | The entity query. | |
ActivityContextBase:: |
protected | property | The entity type manager. | |
ActivityContextBase:: |
public | function | Returns recipients from post. | |
FollowTagActivityContext:: |
public | function |
Returns recipients from followed taxonomies. Overrides FollowTaxonomyActivityContext:: |
|
FollowTaxonomyActivityContext:: |
protected | property | The module handler. | |
FollowTaxonomyActivityContext:: |
public static | function |
Creates an instance of the plugin. Overrides ActivityContextBase:: |
|
FollowTaxonomyActivityContext:: |
public | function | Returns list of field names that needs to check for entity validation. | |
FollowTaxonomyActivityContext:: |
public | function |
Returns a batched list of recipients for this context. Overrides ActivityContextBase:: |
|
FollowTaxonomyActivityContext:: |
public | function |
Determines if the entity is valid for this context. Overrides ActivityContextBase:: |
|
FollowTaxonomyActivityContext:: |
public | function | List of taxonomy terms. | |
FollowTaxonomyActivityContext:: |
public | function |
ActivityContextBase constructor. Overrides ActivityContextBase:: |
|
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:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. |