Score:0

view and context variables does not get passed on VBO custom execute action

in flag

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?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.