Score:0

Plugin not found/invalid plugin error while creating VBO custom action

in flag

I am creating VBO custom action and I constantly see the below error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "publish_TR_action" plugin does not exist. Valid plugin IDs for Drupal\Core\Action\ActionManager are: node_export_action, comment_unpublish_by_keyword_action, entity_delete_action:comment, node_assign_owner_action, node_unpromote_action, node_promote_action, node_make_sticky_action, node_unpublish_by_keyword_action, node_make_unsticky_action, bulk_node_export, user_add_role_action..........

under the module folder I have the below file : /web/modules/custom\mymod/config/install/system.action.publish_comment_action.yml

   langcode: en
status: true
dependencies:
  module:
    - comment
id: publish_TR_action
label: 'Publish comment and create the T&R'
type: ""
plugin: publish_TR_action
configuration: {  }

Next, I made a action class under /src/plugin folder: web/modules/custom/mymod/src/Plugin/Action/PublishTRAction.php

   <?php

namespace Drupal\mymod\Plugin\Action;

use Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * create custom action
 *
 * @Action(
 *   id = "node_export_action",
 *   label = @Translation("Export Content"),
 *   type = "node"
 * )
 */

class PublishTRAction extends ViewsBulkOperationsActionBase {

  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function execute($entity = NULL) {
    // Do some processing..

    // Don't return anything for a default completion message, otherwise return translatable markup.
    return $this->t('Some result');
  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    if ($object->getEntityType() === 'node') {
      $access = $object->access('update', $account, TRUE)
        ->andIf($object->status->access('edit', $account, TRUE));
      return $return_as_object ? $access : $access->isAllowed();
    }

    // Other entity types may have different
    // access methods and properties.
    return TRUE;
  }

}

I uninstalled the module and while re-installing I see the above error. Any help??! I am using Drupal 9.

No Sssweat avatar
ua flag
In your php file you're declaring `"id = node_export_action"`, should be `"id = publish_TR_action"` instead.
Rick avatar
us flag
worked!!! Thanks! can you add this as answer pls?!
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.