You are here

public function EntityProcessorPluginManager::getInstanceByEntityType in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Processors/Entity/EntityProcessorPluginManager.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorPluginManager::getInstanceByEntityType()
  2. 3.x src/Processors/Entity/EntityProcessorPluginManager.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorPluginManager::getInstanceByEntityType()

Get the plugin by bundle type.

Parameters

string $entityType: The entity type id.

Return value

EntityProcessorBase The entity processor base.

File

src/Processors/Entity/EntityProcessorPluginManager.php, line 42

Class

EntityProcessorPluginManager
The entity processor plugin manager.

Namespace

Drupal\content_synchronizer\Processors\Entity

Code

public function getInstanceByEntityType($entityType) {
  $instance = NULL;
  foreach ($this
    ->getDefinitions() as $pluginId => $definition) {
    if ($definition['entityType'] == $entityType) {
      $instance = static::createInstance($pluginId, []);
    }
  }
  if (is_null($instance)) {
    if (!array_key_exists('default', static::$instances)) {
      static::$instances['default'] = new EntityProcessorBase([], 'default', []);
    }
    $instance = static::$instances['default'];
  }
  $instance
    ->setEntityType($entityType);
  return $instance;
}