0

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?

2
  • 1
    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!
    – Clive
    Nov 18 at 13:30
  • thanks for pointing that typo. I fixed it and did everything you mentioned. still same error :(
    – chaydru
    Nov 18 at 13:33
2
  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?
1
  • 2
    it was drush cr :) worked lol
    – chaydru
    Nov 18 at 14:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.