You are here

public function ShortcodeService::loadShortcodePlugins in Shortcode 2.0.x

Same name and namespace in other branches
  1. 8 src/ShortcodeService.php \Drupal\shortcode\ShortcodeService::loadShortcodePlugins()

Returns preprocessed ShortCode plugin definitions.

Return value

array Array of ShortCode plugin definitions.

2 calls to ShortcodeService::loadShortcodePlugins()
ShortcodeService::getShortcodePlugins in src/ShortcodeService.php
Returns array of shortcode plugin definitions enabled for the filter.
ShortcodeService::getShortcodePluginTokens in src/ShortcodeService.php
Returns array of shortcode plugin definitions enabled for the filter.

File

src/ShortcodeService.php, line 36

Class

ShortcodeService
Provide the ShortCode service.

Namespace

Drupal\shortcode

Code

public function loadShortcodePlugins() {

  /** @var \Drupal\Component\Plugin\PluginManagerInterface $type */
  $definitions_raw = $this->shortCodePluginManager
    ->getDefinitions();
  $definitions = [];
  foreach ($definitions_raw as $shortcode_id => $definition) {

    // Default weight to 99.
    if (!isset($definition['weight'])) {
      $definition['weight'] = 99;
    }

    // Default token to id.
    $token = strtolower(isset($definition['token']) ? $definition['token'] : $shortcode_id);
    $definition['token'] = $token;
    $definitions[$shortcode_id] = $definition;
  }
  return $definitions;
}