class ContentReportActivityContext in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- 8.5 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- 8.6 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- 8.7 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- 10.3.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- 10.0.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- 10.1.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- 10.2.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
Provides a 'ContentReportActivityContext' activity context.
Plugin annotation
@ActivityContext(
id = "content_report_activity_context",
label = @Translation("Content report activity context"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
- class \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext
- class \Drupal\activity_creator\Plugin\ActivityContextBase implements ActivityContextInterface, ContainerFactoryPluginInterface
Expanded class hierarchy of ContentReportActivityContext
File
- modules/
social_features/ social_content_report/ src/ Plugin/ ActivityContext/ ContentReportActivityContext.php, line 15
Namespace
Drupal\social_content_report\Plugin\ActivityContextView source
class ContentReportActivityContext extends ActivityContextBase {
/**
* {@inheritdoc}
*/
public function getRecipients(array $data, $last_uid, $limit) {
$recipients = [];
$ids = $this->entityTypeManager
->getStorage('user')
->getQuery()
->condition('status', 1)
->condition('roles', $this
->getRolesWithPermission(), 'IN')
->execute();
if (!empty($ids)) {
// Create a list of recipients in the expected format.
foreach ($ids as $uid) {
$recipients[] = [
'target_type' => 'user',
'target_id' => $uid,
];
}
}
return $recipients;
}
/**
* Returns the role with the required permission.
*
* @return array
* A list of Role IDs.
*/
protected function getRolesWithPermission() {
$roles_with_perm = [];
/* @var \Drupal\user\RoleInterface[] $roles */
$roles = $this->entityTypeManager
->getStorage('user_role')
->loadMultiple();
// Check for each role which one has permission to "view inappropriate
// reports".
foreach ($roles as $role) {
if ($role
->hasPermission('view inappropriate reports')) {
$roles_with_perm[] = $role
->id();
}
}
return $roles_with_perm;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActivityContextBase:: |
private | property | The entity query. | |
ActivityContextBase:: |
protected | property | The entity type manager. | |
ActivityContextBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
3 |
ActivityContextBase:: |
public | function | Returns recipients from post. | |
ActivityContextBase:: |
public | function |
Determines if the entity is valid for this context. Overrides ActivityContextInterface:: |
8 |
ActivityContextBase:: |
public | function |
ActivityContextBase constructor. Overrides PluginBase:: |
3 |
ContentReportActivityContext:: |
public | function |
Returns a batched list of recipients for this context. Overrides ActivityContextBase:: |
|
ContentReportActivityContext:: |
protected | function | Returns the role with the required permission. | |
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. |