DefaultsTestPluginManager.php in Zircon Profile 8
File
core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php
View source
<?php
namespace Drupal\plugin_test\Plugin;
use Drupal\Component\Plugin\Discovery\StaticDiscovery;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class DefaultsTestPluginManager extends DefaultPluginManager {
public function __construct(ModuleHandlerInterface $module_handler) {
$this->discovery = new StaticDiscovery();
$this->factory = new DefaultFactory($this, 'Drupal\\Component\\Plugin\\PluginInspectionInterface');
$this->moduleHandler = $module_handler;
$this->defaults = array(
'metadata' => array(
'default' => TRUE,
),
);
$this->discovery
->setDefinition('test_block1', array(
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\mock_block\\MockTestBlock',
'metadata' => array(
'custom' => TRUE,
),
));
$this->discovery
->setDefinition('test_block2', array(
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\mock_block\\MockTestBlock',
'metadata' => array(
'custom' => TRUE,
'default' => FALSE,
),
));
}
}