You are here

public function RulesEventManager::getDefinition in Rules 8.3

Gets a specific plugin definition.

Parameters

string $plugin_id: A plugin id.

bool $exception_on_invalid: (optional) If TRUE, an invalid plugin ID will throw an exception.

Return value

mixed A plugin definition, or NULL if the plugin ID is invalid and $exception_on_invalid is FALSE.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if $plugin_id is invalid and $exception_on_invalid is TRUE.

Overrides DiscoveryCachedTrait::getDefinition

File

src/Core/RulesEventManager.php, line 70

Class

RulesEventManager
Plugin manager for Rules events that can be triggered.

Namespace

Drupal\rules\Core

Code

public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {

  // If a fully qualified event name is passed, be sure to get the base name
  // first.
  $base_plugin_id = $this
    ->getEventBaseName($plugin_id);
  $definition = parent::getDefinition($base_plugin_id, $exception_on_invalid);
  if ($base_plugin_id != $plugin_id) {
    $parts = explode('--', $plugin_id, 2);
    $entity_type_id = explode(':', $parts[0], 2);
    $bundles = $this->entityBundleInfo
      ->getBundleInfo($entity_type_id[1]);

    // Replace the event label with the fully-qualified label.
    // @todo This is a pretty terrible way of deriving the qualified label
    // for a context definition. And it breaks translation.
    $definition['label'] = $definition['label'] . " of type " . $bundles[$parts[1]]['label'];
  }
  return $definition;
}