You are here

public function RulesComponentRepository::get in Rules 8.3

Gets the component for the given ID.

Parameters

string $id: The ID of the component to get. The supported IDs depend on the given provider. For the default provider 'rules' the entity IDs of component configs may be passed.

string $resolver: The resolver of the component. Supported values are:

  • rules_component: (Default) The component configs identified by their ID.
  • rules_event: The aggregated components of all reaction rules configured for an event, identified by the event name; e.g., 'rules_entity_presave'.

Note, that modules may add further resolvers via tagged services. Check the rules.services.yml for an example.

Return value

\Drupal\rules\Engine\RulesComponent|null The component, or NULL if it is not existing.

Throws

\Drupal\rules\Exception\InvalidArgumentException Thrown if an unsupported provider is given.

Overrides RulesComponentRepositoryInterface::get

File

src/Engine/RulesComponentRepository.php, line 76

Class

RulesComponentRepository
Provides an implementation of the component repository service.

Namespace

Drupal\rules\Engine

Code

public function get($id, $provider = 'rules_component') {
  $result = $this
    ->getMultiple([
    $id,
  ], $provider);
  return reset($result) ?: NULL;
}