class BasicExample
Same name in other branches
- 4.0.x modules/action_example/src/Plugin/Action/BasicExample.php \Drupal\action_example\Plugin\Action\BasicExample
A basic example action that does nothing.
Plugin annotation
@Action(
id = "action_example_basic_action",
label = @Translation("Action Example: A basic example action that does nothing"),
type = "system"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\Core\Action\ActionBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Action\ActionInterface
- class \Drupal\action_example\Plugin\Action\BasicExample extends \Drupal\Core\Action\ActionBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Action\ActionBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Action\ActionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of BasicExample
File
-
modules/
action_example/ src/ Plugin/ Action/ BasicExample.php, line 21
Namespace
Drupal\action_example\Plugin\ActionView source
class BasicExample extends ActionBase implements ContainerFactoryPluginInterface {
/**
* Construct a BasicExample 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\Messenger\MessengerInterface $messenger
* The messenger service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->setMessenger($messenger);
}
/**
* {@inheritDoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('messenger'));
}
/**
* {@inheritdoc}
*/
public function execute($object = NULL) {
$this->messenger()
->addMessage($this->t('action_example_basic_action fired'));
}
/**
* {@inheritDoc}
*/
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$result = AccessResult::allowed();
return $return_as_object ? $result : $result->isAllowed();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ActionBase::executeMultiple | public | function | Executes the plugin for an array of objects. | Overrides ActionInterface::executeMultiple | 3 |
BasicExample::access | public | function | Checks object access. | Overrides ActionInterface::access | |
BasicExample::create | public static | function | Creates an instance of the plugin. | Overrides ContainerFactoryPluginInterface::create | |
BasicExample::execute | public | function | Executes the plugin. | Overrides ExecutableInterface::execute | |
BasicExample::__construct | public | function | Construct a BasicExample object. | ||
PluginInspectionInterface::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | 6 | |
PluginInspectionInterface::getPluginId | public | function | Gets the plugin_id of the plugin instance. | 2 |