class GroupContentInMyGroupActivityContext in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 8.4 modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 8.5 modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 8.6 modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 8.7 modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 10.3.x modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 10.0.x modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 10.1.x modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- 10.2.x modules/custom/activity_basics/src/Plugin/ActivityContext/GroupContentInMyGroupActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
Provides a 'GroupContentInMyGroupActivityContext' activity context.
Plugin annotation
@ActivityContext(
id = "group_content_in_my_group_activity_context",
label = @Translation("Group content in my group activity context"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
- class \Drupal\activity_basics\Plugin\ActivityContext\GroupContentInMyGroupActivityContext
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
Expanded class hierarchy of GroupContentInMyGroupActivityContext
File
- modules/
custom/ activity_basics/ src/ Plugin/ ActivityContext/ GroupContentInMyGroupActivityContext.php, line 21
Namespace
Drupal\activity_basics\Plugin\ActivityContextView source
class GroupContentInMyGroupActivityContext extends ActivityContextBase {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* Constructs a GroupContentInMyGroupActivityContext object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\Query\Sql\QueryFactory $entity_query
* The query factory.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Session\AccountProxyInterface $current_user
* The current user.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, QueryFactory $entity_query, EntityTypeManagerInterface $entity_type_manager, AccountProxyInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_query, $entity_type_manager);
$this->currentUser = $current_user;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity.query.sql'), $container
->get('entity_type.manager'), $container
->get('current_user'));
}
/**
* {@inheritdoc}
*/
public function getRecipients(array $data, $last_uid, $limit) {
$recipients = [];
if (!empty($data['related_object'])) {
$referenced_entity = ActivityFactory::getActivityRelatedEntity($data);
/** @var \Drupal\group\Entity\GroupContentInterface $group_content */
$group_content = $this->entityTypeManager
->getStorage('group_content')
->load($referenced_entity['target_id']);
// It could happen that a notification has been queued but the content
// has since been deleted. In that case we can find no additional
// recipients.
if (!$group_content) {
return $recipients;
}
/** @var \Drupal\group\Entity\GroupInterface $group */
$group = $group_content
->getGroup();
$memberships = $group
->getMembers($group
->bundle() . '-group_manager');
// List of managers which shouldn't receive notifications.
$account_ids = [
// The current user when he/she is a manager.
$this->currentUser
->id(),
// New group member with the "Group manager" role.
$group_content
->getEntity()
->id(),
];
/** @var \Drupal\group\GroupMembership $membership */
foreach ($memberships as $membership) {
if (!in_array($membership
->getUser()
->id(), $account_ids)) {
$recipients[] = [
'target_type' => 'user',
'target_id' => $membership
->getUser()
->id(),
];
}
}
}
return $recipients;
}
/**
* {@inheritdoc}
*/
public function isValidEntity(EntityInterface $entity) {
return $entity
->getEntityTypeId() === 'group_content';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActivityContextBase:: |
private | property | The entity query. | |
ActivityContextBase:: |
protected | property | The entity type manager. | |
ActivityContextBase:: |
public | function | Returns recipients from post. | |
GroupContentInMyGroupActivityContext:: |
protected | property | The current user. | |
GroupContentInMyGroupActivityContext:: |
public static | function |
Creates an instance of the plugin. Overrides ActivityContextBase:: |
|
GroupContentInMyGroupActivityContext:: |
public | function |
Returns a batched list of recipients for this context. Overrides ActivityContextBase:: |
|
GroupContentInMyGroupActivityContext:: |
public | function |
Determines if the entity is valid for this context. Overrides ActivityContextBase:: |
|
GroupContentInMyGroupActivityContext:: |
public | function |
Constructs a GroupContentInMyGroupActivityContext object. 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:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. |