You are here

public function ShortcodeService::getShortcodePlugin in Shortcode 8

Same name and namespace in other branches
  1. 2.0.x src/ShortcodeService.php \Drupal\shortcode\ShortcodeService::getShortcodePlugin()

Creates ShortCode plugin instance or loads from static cache.

Parameters

string $shortcode_id: The shorShortCodetcode plugin id.

Return value

\Drupal\shortcode\Plugin\ShortcodeInterface The plugin instance.

1 call to ShortcodeService::getShortcodePlugin()
ShortcodeService::processTag in src/ShortcodeService.php
Regular Expression callable for do_shortcode() for calling Shortcode hook.

File

src/ShortcodeService.php, line 158

Class

ShortcodeService
Provide the ShortCode service.

Namespace

Drupal\shortcode

Code

public function getShortcodePlugin($shortcode_id) {
  $plugins =& drupal_static(__FUNCTION__, []);
  if (!isset($plugins[$shortcode_id])) {

    /** @var \Drupal\shortcode\Shortcode\ShortcodePluginManager $type */
    $type = \Drupal::service('plugin.manager.shortcode');
    $plugins[$shortcode_id] = $type
      ->createInstance($shortcode_id);
  }
  return $plugins[$shortcode_id];
}