You are here

public function ConsentUserResolverPluginManager::getForEntityType in General Data Protection Regulation 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/gdpr_consent/src/ConsentUserResolver/ConsentUserResolverPluginManager.php \Drupal\gdpr_consent\ConsentUserResolver\ConsentUserResolverPluginManager::getForEntityType()
  2. 8 modules/gdpr_consent/src/ConsentUserResolver/ConsentUserResolverPluginManager.php \Drupal\gdpr_consent\ConsentUserResolver\ConsentUserResolverPluginManager::getForEntityType()

Finds a resolver for the specified entity type/bundle.

Parameters

string $entityType: The entity type.

string $bundle: The bundle.

Return value

\Drupal\gdpr_consent\ConsentUserResolver\GdprConsentUserResolverInterface The resolver that will be used to find the User for a specific entity.

Throws

\Exception

File

modules/gdpr_consent/src/ConsentUserResolver/ConsentUserResolverPluginManager.php, line 118

Class

ConsentUserResolverPluginManager
Class ConsentUserResolverPluginManager.

Namespace

Drupal\gdpr_consent\ConsentUserResolver

Code

public function getForEntityType($entityType, $bundle) {
  $definition = $this
    ->getDefinitionForType($entityType, $bundle);
  if (FALSE === $definition) {
    throw new \Exception("Could not determine user ID for entity type {$entityType}. Please ensure there is a resolver registered.");
  }
  return $this
    ->createInstance($definition['id']);
}