You are here

public function ImageEffectsPluginManager::getPlugin in Image Effects 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageEffectsPluginManager.php \Drupal\image_effects\Plugin\ImageEffectsPluginManager::getPlugin()
  2. 8.2 src/Plugin/ImageEffectsPluginManager.php \Drupal\image_effects\Plugin\ImageEffectsPluginManager::getPlugin()

Returns an instance of the specified 'image_effects' plugin.

Parameters

string $plugin_id: The plugin id.

Return value

\Drupal\image_effects\Plugin\ImageEffectsPluginBaseInterface An instance of the specified 'image_effects' plugin.

File

src/Plugin/ImageEffectsPluginManager.php, line 69

Class

ImageEffectsPluginManager
Plugin manager for image_effects plugins.

Namespace

Drupal\image_effects\Plugin

Code

public function getPlugin($plugin_id = NULL) {
  $plugin_id = $plugin_id ?: $this->config
    ->get($this
    ->getType() . '.plugin_id');
  $plugins = $this
    ->getAvailablePlugins();

  // Check if plugin is available.
  if (!isset($plugins[$plugin_id]) || !class_exists($plugins[$plugin_id]['class'])) {
    trigger_error("image_effects " . $this
      ->getType() . " handling plugin '{$plugin_id}' is no longer available.", E_USER_ERROR);
    $plugin_id = NULL;
  }
  return $this
    ->createInstance($plugin_id, [
    'plugin_type' => $this
      ->getType(),
  ]);
}