class CommentFlagType in Flag 8.4
Provides a flag type for comments.
Plugin annotation
@FlagType(
id = "entity:comment",
title = @Translation("Comment"),
entity_type = "comment",
provider = "comment"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\flag\FlagType\FlagTypeBase implements FlagTypePluginInterface uses StringTranslationTrait
- class \Drupal\flag\Plugin\Flag\EntityFlagType uses StringTranslationTrait
- class \Drupal\flag\Plugin\Flag\CommentFlagType
- class \Drupal\flag\Plugin\Flag\EntityFlagType uses StringTranslationTrait
- class \Drupal\flag\FlagType\FlagTypeBase implements FlagTypePluginInterface uses StringTranslationTrait
Expanded class hierarchy of CommentFlagType
File
- src/
Plugin/ Flag/ CommentFlagType.php, line 17
Namespace
Drupal\flag\Plugin\FlagView source
class CommentFlagType extends EntityFlagType {
/**
* {@inheritdoc}
*/
protected function getExtraPermissionsOptions() {
$options = parent::getExtraPermissionsOptions();
$options['parent_owner'] = $this
->t("Permissions based on ownership of a comment's parent entity.");
return $options;
}
/**
* {@inheritdoc}
*/
public function actionPermissions(FlagInterface $flag) {
$permissions = parent::actionPermissions($flag);
if (!empty($this->configuration['extra_permissions'])) {
foreach ($this->configuration['extra_permissions'] as $option) {
switch ($option) {
// The 'owner' case is handled by the parent method.
case 'parent_owner':
// Define additional permissions.
$permissions['flag ' . $flag
->id() . ' comments on own parent entities'] = [
'title' => $this
->t('Flag %flag_title comments on own parent entities', [
'%flag_title' => $flag
->label(),
]),
];
$permissions['unflag ' . $flag
->id() . ' comments on own parent entities'] = [
'title' => $this
->t('Unflag %flag_title on own parent entities', [
'%flag_title' => $flag
->label(),
]),
];
$permissions['flag ' . $flag
->id() . ' comments on other parent entities'] = [
'title' => $this
->t("Flag %flag_title on others' parent entities", [
'%flag_title' => $flag
->label(),
]),
];
$permissions['unflag ' . $flag
->id() . ' comments on other parent entities'] = [
'title' => $this
->t("Unflag %flag_title on others' parent entities", [
'%flag_title' => $flag
->label(),
]),
];
break;
}
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommentFlagType:: |
public | function |
Returns the permissions available to this flag type. Overrides EntityFlagType:: |
|
CommentFlagType:: |
protected | function |
Defines options for extra permissions. Overrides EntityFlagType:: |
|
EntityFlagType:: |
protected | property | The entity type defined in plugin definition. | |
EntityFlagType:: |
protected | property | The entity type manager. | |
EntityFlagType:: |
public | function |
Checks whether a user has permission to flag/unflag or not. Overrides FlagTypeBase:: |
3 |
EntityFlagType:: |
public | function |
Provides a form for this action link plugin settings. Overrides FlagTypeBase:: |
1 |
EntityFlagType:: |
public static | function |
Creates an instance of the plugin. Overrides FlagTypeBase:: |
|
EntityFlagType:: |
public | function |
Gets default configuration for this plugin. Overrides FlagTypeBase:: |
1 |
EntityFlagType:: |
protected | function | Defines permissions for the 'owner' set of additional action permissions. | 1 |
EntityFlagType:: |
public | function | Determines if the given form operation is add or edit. | 1 |
EntityFlagType:: |
protected | function | Determines if the flaggable associated with the flag supports ownership. | 1 |
EntityFlagType:: |
public | function | Returns the show as field setting. | |
EntityFlagType:: |
public | function | Returns the show on contextual link setting. | |
EntityFlagType:: |
public | function | Return the show in links setting given a view mode. | |
EntityFlagType:: |
public | function | Returns the show on form setting. | |
EntityFlagType:: |
public | function |
Handles the form submit for this action link plugin. Overrides FlagTypeBase:: |
1 |
EntityFlagType:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides FlagTypeBase:: |
|
FlagTypeBase:: |
protected | property | The module handler. | |
FlagTypeBase:: |
public | function | ||
FlagTypeBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
FlagTypeBase:: |
protected | function | Determines whether the flag is set to have the extra permissions set. | |
FlagTypeBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
FlagTypeBase:: |
public | function |
Handles the validation for the action link plugin settings form. Overrides PluginFormInterface:: |
|
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. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |