You are here

class EventBasedDefaultPluginResolver in Plugin 8.2

Provides an event-based default plugin resolver.

Hierarchy

Expanded class hierarchy of EventBasedDefaultPluginResolver

1 file declares its use of EventBasedDefaultPluginResolver
EventBasedDefaultPluginResolverTest.php in tests/src/Unit/DefaultPluginResolver/EventBasedDefaultPluginResolverTest.php
1 string reference to 'EventBasedDefaultPluginResolver'
plugin.services.yml in ./plugin.services.yml
plugin.services.yml
1 service uses EventBasedDefaultPluginResolver
plugin.default_plugin_resolver in ./plugin.services.yml
Drupal\plugin\DefaultPluginResolver\EventBasedDefaultPluginResolver

File

src/DefaultPluginResolver/EventBasedDefaultPluginResolver.php, line 13

Namespace

Drupal\plugin\DefaultPluginResolver
View source
class EventBasedDefaultPluginResolver implements DefaultPluginResolverInterface {

  /**
   * The event dispatcher.
   *
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
   */
  protected $eventDispatcher;

  /**
   * Creates a new instance.
   *
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
   */
  public function __construct(EventDispatcherInterface $event_dispatcher) {
    $this->eventDispatcher = $event_dispatcher;
  }

  /**
   * {@inheritdoc}
   */
  public function createDefaultPluginInstance(PluginTypeInterface $plugin_type) {
    $event = new ResolveDefaultPlugin($plugin_type);
    $this->eventDispatcher
      ->dispatch(PluginEvents::RESOLVE_DEFAULT_PLUGIN, $event);
    return $event
      ->getDefaultPluginInstance();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EventBasedDefaultPluginResolver::$eventDispatcher protected property The event dispatcher.
EventBasedDefaultPluginResolver::createDefaultPluginInstance public function Creates a default plugin instance of a given plugin type. Overrides DefaultPluginResolverInterface::createDefaultPluginInstance
EventBasedDefaultPluginResolver::__construct public function Creates a new instance.