You are here

protected function EntityTypeAnalyzer::getBundle in Mailhandler 8

Returns the extracted bundle name.

Parameters

string $entity_type: The extracted entity type name.

string $bundle: The extracted bundle name.

Return value

string|null The bundle name or null if not valid.

1 call to EntityTypeAnalyzer::getBundle()
EntityTypeAnalyzer::findEntityType in src/Plugin/inmail/Analyzer/EntityTypeAnalyzer.php
Analyzes the message subject to extract entity type and bundle information.

File

src/Plugin/inmail/Analyzer/EntityTypeAnalyzer.php, line 89

Class

EntityTypeAnalyzer
An entity type and bundle analyzer.

Namespace

Drupal\mailhandler\Plugin\inmail\Analyzer

Code

protected function getBundle($entity_type, $bundle) {
  if (\Drupal::entityTypeManager()
    ->getDefinition($entity_type, FALSE)
    ->hasKey('bundle')) {
    $bundles = \Drupal::service('entity_type.bundle.info')
      ->getBundleInfo($entity_type);
    if (in_array($bundle, array_keys($bundles))) {
      return $bundle;
    }
  }
  return NULL;
}