Plugin not found

in flag

I am overwriting the CommentBulkForm class in my module.

namespace Drupal\mymod\Plugin\views\field;

use Drupal\comment\Plugin\views\field\CommentBulkForm;

 * Defines a custom comment operations bulk form element.
 * @ViewsField("custom_comment_bulk_form")
class CustomCommentBulkForm extends CommentBulkForm {

   * {@inheritdoc}
  protected function emptySelectedMessage() {
    return $this->t('some other message.');


This file is placed inside mymodule\src\Plugin\views\field. I overwrote the views.view.comment to look for this class. However, I get the following error when I try to load the comments view.

Drupal\Component\Plugin\Exception\PluginException: Plugin (custom_comment_bulk_form) instance class "Drupal\mymod\Plugin\views\field\custom_comment_bulk_form" does not exist. in Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (line 97 of /vagrant/web/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php).

What's wrong in the code?

cn flag
Could you clean up the module names in the question a bit, just to confirm the problem isn't a typo? You have three listed: ahrq in the code, mymodule in the example path, and mymod in the error message. If you could also confirm that you've cleared cache, the module is enabled, and you've restarted the web server (to flush APCu which can sometimes get in the way), that would be helpful too. Thanks!
in flag
thanks for pointing that typo. I fixed it and did everything you mentioned. still same error :(
ch flag
  1. For PSR-2 loading to work is important:
  • Check namespace, folders are coherent. If your module is ahrq, ensure the namespace uses ahrq, and the folder it sits is ahrq/src/Plugin/views/field. Check the casing is respected just in case (lowercase/uppercase matters).

  • Ensure the file is named CustomCommentBulkForm.php

  1. Yeah, obvious, but have you cleared your cache?
in flag
it was drush cr :) worked lol

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.