You are here

public function Manager::createInstance in Message Notify 8

Allow the message entity to be passed to the constructor.

Overrides PluginManagerBase::createInstance

File

src/Plugin/Notifier/Manager.php, line 20

Class

Manager
Notifier plugin manager.

Namespace

Drupal\message_notify\Plugin\Notifier

Code

public function createInstance($plugin_id, array $configuration = [], MessageInterface $message = NULL) {
  $plugin_definition = $this
    ->getDefinition($plugin_id);
  $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);

  // If the plugin provides a factory method, pass the container to it.
  if (is_subclass_of($plugin_class, ContainerFactoryPluginInterface::class)) {
    $plugin = $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition, $message);
  }
  else {
    $plugin = new $plugin_class($configuration, $plugin_id, $plugin_definition, $message);
  }
  return $plugin;
}