A wrong logs PluginManagerBase

Created on 20 August 2019, about 5 years ago
Updated 14 July 2024, about 2 months ago

When I created this a simple block I got this error message

The "test12" was not found

But it is a wrong message. It should be this message

The "txonomy_term" was not found


namespace Drupal\g_media\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a block.
 *
 * @Block(
 *  id = "test12",
 *  admin_label = @Translation("A custom block"),
 * )
 */
class SliderNamesTreeBlock extends BlockBase implements ContainerFactoryPluginInterface {

  /**
   * The taxonomy term storage.
   *
   * @var \Drupal\taxonomy\TermStorageInterface
   */
  protected $termStorage;

  /**
   * The renderer.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * Constructs a new SystemBreadcrumbBlock object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    EntityTypeManagerInterface $entity_type_manager
  ) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->termStorage = $entity_type_manager->getStorage('txonomy_term');
  }

  /**
   * {@inheritdoc}
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public static function create(
    ContainerInterface $container,
    array $configuration,
    $plugin_id,
    $plugin_definition
  ) {
    /*  @noinspection  PhpParamsInspection */
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('entity_type.manager')
    );
  }

  /**
   * {@inheritdoc}
   *
   * @throws \Exception
   */
  public function build() {
    return [
      '#markup' => 'Test',
    ];
  }

}

πŸ› Bug report
Status

Closed: cannot reproduce

Version

11.0 πŸ”₯

Component
PluginΒ  β†’

Last updated about 15 hours ago

Created by

πŸ‡ΊπŸ‡¦Ukraine MykolaVeryha

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    @Mykola Veriga, Thank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.

    The error message is from the BlockManager, when the plugin can not be found. In this case, the plugin "test12" was not discovered which suggests a problem in the custom code. Did you resolve this problem?

    If not, can you explain why you expected a different error message?

    Since we need more information to move forward with this issue, I am setting the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • Issue was unassigned.
  • Status changed to Closed: cannot reproduce about 2 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    More information was asked for 7 months ago and none has been provided. Therefore, closing as cannot reproduce. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue β†’ (starting from "Install Drupal core").

    Thanks!

Production build 0.71.5 2024