manager = $manager; $this->addInstanceId($instance_id, $configuration); } /** * {@inheritdoc} */ protected function initializePlugin($instance_id) { $this->set($instance_id, $this->manager->createInstance($instance_id, $this->configuration)); } /** * {@inheritdoc} */ public function getConfiguration() { $plugin = $this->get($this->instanceId); if ($plugin instanceof ConfigurableInterface) { return $plugin->getConfiguration(); } else { return $this->configuration; } } /** * {@inheritdoc} */ public function setConfiguration($configuration) { if (!is_array($configuration)) { @trigger_error('Calling ' . __METHOD__ . '() with a non-array argument is deprecated in drupal:10.3.0 and will fail in drupal:11.0.0. See https://www.drupal.org/node/3406191', E_USER_DEPRECATED); $configuration = []; } $this->configuration = $configuration; $plugin = $this->get($this->instanceId); if ($plugin instanceof ConfigurableInterface) { $plugin->setConfiguration($configuration); } return $this; } /** * {@inheritdoc} */ public function addInstanceId($id, $configuration = NULL) { $this->instanceId = $id; // Reset the list of instance IDs since there can be only one. $this->instanceIds = []; parent::addInstanceId($id, $configuration); if ($configuration !== NULL) { $this->setConfiguration($configuration); } } }