trait ExecutablePluginTrait in Rules 8.3
Offers common methods for executable plugins.
Hierarchy
- trait \Drupal\rules\Core\ExecutablePluginTrait
File
- src/
Core/ ExecutablePluginTrait.php, line 10
Namespace
Drupal\rules\CoreView source
trait ExecutablePluginTrait {
/**
* Get the translated label from the plugin definition.
*
* @return string
* The label of the plugin.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* Thrown if the label is not defined for the plugin.
*/
protected function getLabelValue() {
$definition = $this
->getPluginDefinition();
if (empty($definition['label'])) {
throw new InvalidPluginDefinitionException('The label is not defined for plugin ' . $this
->getPluginId() . ' (' . __CLASS__ . ').');
}
// The label can be an instance of
// \Drupal\Core\StringTranslation\TranslatableMarkup here, so make sure to
// always return a primitive string representation here.
return (string) $definition['label'];
}
/**
* Get the translated summary from the label annotation.
*
* @return string
* The summary of the plugin.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* Thrown if a summary was not set.
*/
public function summary() {
return $this
->getLabelValue();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExecutablePluginTrait:: |
protected | function | Get the translated label from the plugin definition. | |
ExecutablePluginTrait:: |
public | function | Get the translated summary from the label annotation. | 4 |