/** * {@inheritdoc} */ public function createInstance($plugin_id, array $configuration = []) { // Normally we must never interact with plugins' internal configuration, // but Drupal core's entity reference selection plugins require such // interaction, as they fail to provide APIs for setting required // configuration. See https://www.drupal.org/node/2636322. $default_configuration = ['target_type' => $this->targetEntityTypeId, 'handler_settings' => ['sort' => ['direction' => 'ASC', 'field' => NULL], 'target_bundles' => []]]; $configuration = NestedArray::mergeDeep($default_configuration, $configuration); return parent::createInstance($plugin_id, $configuration); }
/** * Creates a new instance. * * @param \Drupal\payment\Entity\PaymentInterface $payment * The payment to inject into payment-aware plugin instances. * @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager * The decorated plugin manager. * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface|null $discovery * A plugin discovery to use instead of the decorated plugin manager, or * NULL to use the decorated plugin manager. */ public function __construct(PaymentInterface $payment, PluginManagerInterface $plugin_manager, DiscoveryInterface $discovery = NULL) { parent::__construct($plugin_manager, $discovery); $this->payment = $payment; }
/** * @covers ::getInstance * * @expectedException \BadMethodCallException */ public function testGetInstance() { $plugin_manager = $this->getMock(PluginManagerInterface::class); $this->sut = new PluginManagerDecorator($plugin_manager); $this->sut->getInstance([]); }