9 – Can’t get annotated plugin discovery to fire

I’ve checked Debug plugin discovery and tried restarting Apache and setting $settings(‘class_loader_auto_detect’) = FALSE; in settings.php, with no change.

I have a custom module. Setting a breakpoint anywhere that I know should fire works, including the config form for my module.

The module defines a plugin of the annotated type, and I cannot get any code in the plugin manager to fire. I also note that I’ve used a contrib module as a model, and cannot get code in its plugin manager to break either.

If I refer to the module as ‘x’, in
x/src/XManager.php I have:

namespace Drupalx;

use DrupalCoreCacheCacheBackendInterface;
use DrupalCoreExtensionModuleHandlerInterface;
use DrupalCorePluginDefaultPluginManager;
use DrupalxAnnotationX;

/**
 * Class XManager
 *
 * @package Drupalx
 */
class XManager extends DefaultPluginManager {

  public function __construct(Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
    $subdir = 'Plugin/X';
    $plugin_interface = XInterface::class;
    $plugin_definition_annotation_name = X::class;
    parent::__construct($subdir, $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name);
    $this->alterInfo('x_info');
    $this->setCacheBackend($cache_backend, 'x_plugins');
  }
  
}

and in x/src/Annotation/X.php

namespace DrupalxAnnotation;

use DrupalComponentAnnotationPlugin;

/**
 * @see plugin_api
 *
 * @Annotation
 */
class X extends Plugin {

  /**
   * The plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The plugin label.
   *
   * @var DrupalCoreAnnotationTranslation
   *
   * @ingroup plugin_translatable
   */
  public $label;

  /**
   * The plugin field type IDs.
   *
   * @var array
   */
  public $field_type_ids = ();

}

and in x/src/Plugin/X/XTest.php

namespace DrupalxPluginXTest;

/**
 * Class XTest.
 *
 * @X(
 *   id = "x_test",
 *   label = @Translation("X Test"),
 *   field_types = {
 *     "text",
 *     "text_long",
 *     "text_with_summary",
 *   },
 *
 * )
 */
class XTest {

}