TestLazyPluginCollection.php in Drupal 9
File
core/modules/system/tests/modules/plugin_test/src/Plugin/TestLazyPluginCollection.php
View source
<?php
namespace Drupal\plugin_test\Plugin;
use Drupal\Component\Plugin\LazyPluginCollection;
use Drupal\Component\Plugin\PluginManagerInterface;
class TestLazyPluginCollection extends LazyPluginCollection {
protected $manager;
public function __construct(PluginManagerInterface $manager) {
$this->manager = $manager;
$instance_ids = array_keys($this->manager
->getDefinitions());
$this->instanceIds = array_combine($instance_ids, $instance_ids);
}
protected function initializePlugin($instance_id) {
$this->pluginInstances[$instance_id] = $this->manager
->createInstance($instance_id, []);
}
public function getConfiguration() {
return [];
}
public function setConfiguration($configuration) {
return $this;
}
}