You are here

public function RabbitHoleEntityPluginManager::createInstanceByEntityType in Rabbit Hole 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/RabbitHoleEntityPluginManager.php \Drupal\rabbit_hole\Plugin\RabbitHoleEntityPluginManager::createInstanceByEntityType()

Create an instance of the first plugin found with string id $entity_type.

Create an instance of the first plugin found supporting the entity type with string id $entity_type.

Parameters

string $entity_type: The string ID of the entity type.

Return value

\Drupal\rabbit_hole\Plugin\RabbitHoleEntityPluginInterface The plugin.

File

src/Plugin/RabbitHoleEntityPluginManager.php, line 61

Class

RabbitHoleEntityPluginManager
Provides the Rabbit hole entity plugin plugin manager.

Namespace

Drupal\rabbit_hole\Plugin

Code

public function createInstanceByEntityType($entity_type) {
  $plugin_ids = array_keys($this
    ->loadDefinitionsByEntityType($entity_type));
  return $this
    ->createInstance($plugin_ids[0]);
}