You are here

public function EntityPrintPluginManager::createInstance in Entity Print 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/EntityPrintPluginManager.php \Drupal\entity_print\Plugin\EntityPrintPluginManager::createInstance()

Creates a pre-configured instance of a plugin.

Parameters

string $plugin_id: The ID of the plugin being instantiated.

array $configuration: An array of configuration relevant to the plugin instance.

Return value

object A fully configured plugin instance.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.

Overrides PluginManagerBase::createInstance

1 call to EntityPrintPluginManager::createInstance()
EntityPrintPluginManager::createSelectedInstance in src/Plugin/EntityPrintPluginManager.php
Gets currently selected plugin for this export type.

File

src/Plugin/EntityPrintPluginManager.php, line 77

Class

EntityPrintPluginManager
Entity print plugin manager.

Namespace

Drupal\entity_print\Plugin

Code

public function createInstance($plugin_id, array $configuration = []) {
  $configuration = array_merge($this
    ->getPrintEngineSettings($plugin_id), $configuration);

  /** @var \Drupal\entity_print\Plugin\PrintEngineInterface $class */
  $definition = $this
    ->getDefinition($plugin_id);
  $class = $definition['class'];

  // Throw an exception if someone tries to use a plugin that doesn't have all
  // of its dependencies met.
  if (!$class::dependenciesAvailable()) {
    throw new PrintEngineException(sprintf('Missing dependencies. %s', $class::getInstallationInstructions()));
  }
  return parent::createInstance($plugin_id, $configuration);
}