class GroupNode in Group 2.0.x
Provides a group relation for nodes.
Plugin annotation
@GroupContentEnabler(
id = "group_node",
label = @Translation("Group node"),
description = @Translation("Adds nodes to groups both publicly and privately."),
entity_type_id = "node",
entity_access = TRUE,
reference_label = @Translation("Title"),
reference_description = @Translation("The title of the node to add to the group"),
deriver = "Drupal\gnode\Plugin\Group\Relation\GroupNodeDeriver",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\group\Plugin\Group\Relation\GroupRelationBase implements GroupRelationInterface
- class \Drupal\gnode\Plugin\Group\Relation\GroupNode
- class \Drupal\group\Plugin\Group\Relation\GroupRelationBase implements GroupRelationInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of GroupNode
File
- modules/
gnode/ src/ Plugin/ Group/ Relation/ GroupNode.php, line 25
Namespace
Drupal\gnode\Plugin\Group\RelationView source
class GroupNode extends GroupRelationBase {
/**
* Retrieves the node type this plugin supports.
*
* @return \Drupal\node\NodeTypeInterface
* The node type this plugin supports.
*/
protected function getNodeType() {
return NodeType::load($this
->getEntityBundle());
}
/**
* {@inheritdoc}
*/
public function getGroupOperations(GroupInterface $group) {
$account = \Drupal::currentUser();
$plugin_id = $this
->getPluginId();
$type = $this
->getEntityBundle();
$operations = [];
if ($group
->hasPermission("create {$plugin_id} entity", $account)) {
$route_params = [
'group' => $group
->id(),
'plugin_id' => $plugin_id,
];
$operations["gnode-create-{$type}"] = [
'title' => $this
->t('Add @type', [
'@type' => $this
->getNodeType()
->label(),
]),
'url' => new Url('entity.group_content.create_form', $route_params),
'weight' => 30,
];
}
return $operations;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$config = parent::defaultConfiguration();
$config['entity_cardinality'] = 1;
return $config;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
// Disable the entity cardinality field as the functionality of this module
// relies on a cardinality of 1. We don't just hide it, though, to keep a UI
// that's consistent with other group relation plugins.
$info = $this
->t("This field has been disabled by the plugin to guarantee the functionality that's expected of it.");
$form['entity_cardinality']['#disabled'] = TRUE;
$form['entity_cardinality']['#description'] .= '<br /><em>' . $info . '</em>';
return $form;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
$dependencies = parent::calculateDependencies();
$dependencies['config'][] = 'node.type.' . $this
->getEntityBundle();
return $dependencies;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
GroupNode:: |
public | function |
Form constructor. Overrides GroupRelationBase:: |
|
GroupNode:: |
public | function |
Calculates dependencies for the configured plugin. Overrides GroupRelationBase:: |
|
GroupNode:: |
public | function |
Gets default configuration for this plugin. Overrides GroupRelationBase:: |
|
GroupNode:: |
public | function |
Provides a list of operations for a group. Overrides GroupRelationBase:: |
|
GroupNode:: |
protected | function | Retrieves the node type this plugin supports. | |
GroupRelationBase:: |
protected | property | The ID of group type this plugin was instantiated for. | |
GroupRelationBase:: |
private | property | Backwards compatible permission array. | |
GroupRelationBase:: |
public | function |
Returns whether this plugin defines entity access. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
GroupRelationBase:: |
public | function |
Retrieves the label for a piece of group content. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns a safe, unique configuration ID for a group content type. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the administrative description for a group content type. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the administrative label for a group content type. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the administrative description for the plugin. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the entity bundle the plugin supports. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the amount of times the same content can be added to a group. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the description for the entity reference field. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the label for the entity reference field. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns a list of entity reference field settings. Overrides GroupRelationInterface:: |
1 |
GroupRelationBase:: |
protected | function | Returns the entity type definition the plugin supports. | |
GroupRelationBase:: |
public | function |
Returns the entity type ID the plugin supports. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the amount of groups the same content can be added to. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Provides the cacheable metadata for this plugin's group operations. Overrides GroupRelationInterface:: |
1 |
GroupRelationBase:: |
public | function |
Returns the group type the plugin was instantiated for. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the ID of the group type the plugin was instantiated for. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the administrative label for the plugin. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Provides a list of operations for the group relation plugin. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the pretty path key for use in path aliases. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns the plugin provider. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns whether this plugin can only be (un)installed through code. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Returns whether this plugin is always on. Overrides GroupRelationInterface:: |
|
GroupRelationBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
GroupRelationBase:: |
public | function |
Only override this function if you need to do something specific to the
submitted data before it is saved as configuration on the plugin. The data
gets saved on the plugin in \Drupal\group\Entity\Form\GroupContentTypeForm. Overrides PluginFormInterface:: |
|
GroupRelationBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
GroupRelationBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |