You are here

public function ContainerAwarePluginManager::getInstance in Service Container 7.2

Same name and namespace in other branches
  1. 7 src/Plugin/ContainerAwarePluginManager.php \Drupal\service_container\Plugin\ContainerAwarePluginManager::getInstance()

Gets a preconfigured instance of a plugin.

Parameters

array $options: An array of options that can be used to determine a suitable plugin to instantiate and how to configure it.

Return value

object|false A fully configured plugin instance. The interface of the plugin instance will depends on the plugin type. If no instance can be retrieved, FALSE will be returned.

Overrides MapperInterface::getInstance

File

src/Plugin/ContainerAwarePluginManager.php, line 85
Contains \Drupal\service_container\Plugin\ContainerAwarePluginManager

Class

ContainerAwarePluginManager
Base class for plugin managers.

Namespace

Drupal\service_container\Plugin

Code

public function getInstance(array $options) {

  // 90% of core does not use the generic $mapper functionality, so use a
  // sane default function.
  if (isset($options['id'])) {
    return $this
      ->createInstance($options['id']);
  }
  return FALSE;
}