0

I have created a custom VBO action and below is my code for the customaction.php. The action is getting created perfectly fine, however the $view and $context variables are not getting passed through. They are all getting null. Below is the custom action code:

    namespace Drupal\mymod\Plugin\Action;
    
    use Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase;
    
    /**
     * create custom action
     *
     * @Action(
     *   id = "custom_action",
     *   label = @Translation("custom action"),
     *   type = "",
     *   confirm = TRUE,
     *   pass_context = TRUE,
     *   pass_view = TRUE,
     *   requirements = {
     *     "_custom_access" = TRUE,
     *   },
     * )
     */
    
    class customaction extends ViewsBulkOperationsActionBase {
    
      use StringTranslationTrait;
    
      /**
       * {@inheritdoc}
       */
    
      public function execute(ContentEntityInterface $entity = NULL) {
    dpm($this);
//custom action code....
    }
      /**
       * {@inheritdoc}
       */
      public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) .....

doing a dpm($this) inside the execute method returns the below output:

enter image description here

I am using VBO 4.0 version. Any help on identifying the mistake?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.