You are here

protected function ExtraFieldDisplayManager::matchEntityBundleKey in Extra Field 8

Checks if the plugin bundle definition matches the entity bundle key.

Parameters

string[] $pluginBundles: Defines which entity-bundle pair the plugin can be used for. Format: [entity type].[bundle] or [entity type].* .

string $entityBundleKey: The entity-bundle string of a content entity. Format: [entity type].[bundle] .

Return value

bool True of the plugin bundle definition matches the entity bundle key.

1 call to ExtraFieldDisplayManager::matchEntityBundleKey()
ExtraFieldDisplayManager::entityView in src/Plugin/ExtraFieldDisplayManager.php
Appends the renderable data from ExtraField plugins to hook_entity_view().

File

src/Plugin/ExtraFieldDisplayManager.php, line 122

Class

ExtraFieldDisplayManager
Manages Extra Field plugins.

Namespace

Drupal\extra_field\Plugin

Code

protected function matchEntityBundleKey(array $pluginBundles, $entityBundleKey) {
  $match = FALSE;
  foreach ($pluginBundles as $pluginBundle) {
    if (strpos($pluginBundle, '.*')) {
      $match = explode('.', $pluginBundle)[0] == explode('.', $entityBundleKey)[0];
    }
    else {
      $match = $pluginBundle == $entityBundleKey;
    }
    if ($match) {
      break;
    }
  }
  return $match;
}