function RulesEventManager::getDefinition

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;
}