You are here

public function ViewsBulkOperationExampleAction::execute in Views Bulk Operations (VBO) 4.0.x

Same name and namespace in other branches
  1. 8.3 modules/views_bulk_operations_example/src/Plugin/Action/ViewsBulkOperationExampleAction.php \Drupal\views_bulk_operations_example\Plugin\Action\ViewsBulkOperationExampleAction::execute()
  2. 8 modules/views_bulk_operations_example/src/Plugin/Action/ViewsBulkOperationExampleAction.php \Drupal\views_bulk_operations_example\Plugin\Action\ViewsBulkOperationExampleAction::execute()
  3. 8.2 modules/views_bulk_operations_example/src/Plugin/Action/ViewsBulkOperationExampleAction.php \Drupal\views_bulk_operations_example\Plugin\Action\ViewsBulkOperationExampleAction::execute()

Executes the plugin.

Overrides ExecutableInterface::execute

File

modules/views_bulk_operations_example/src/Plugin/Action/ViewsBulkOperationExampleAction.php, line 29

Class

ViewsBulkOperationExampleAction
An example action covering most of the possible options.

Namespace

Drupal\views_bulk_operations_example\Plugin\Action

Code

public function execute($entity = NULL) {

  /*
   * All config resides in $this->configuration.
   * Passed view rows will be available in $this->context.
   * Data about the view used to select results and optionally
   * the batch context are available in $this->context or externally
   * through the public getContext() method.
   * The entire ViewExecutable object  with selected result
   * rows is available in $this->view or externally through
   * the public getView() method.
   */

  // Do some processing..
  // ...
  $this
    ->messenger()
    ->addMessage($entity
    ->label() . ' - ' . $entity
    ->language()
    ->getId() . ' - ' . $entity
    ->id());
  return sprintf('Example action (configuration: %s)', print_r($this->configuration, TRUE));
}