You are here

public function Flow::getFieldHandler in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Flow.php \Drupal\cms_content_sync\Entity\Flow::getFieldHandler()

Get the correct field handler instance for this entity type and field config.

Parameters

$entity_type_name:

$bundle_name:

$field_name:

Return value

\Drupal\cms_content_sync\Plugin\FieldHandlerInterface

File

src/Entity/Flow.php, line 954

Class

Flow
Defines the "Content Sync - Flow" entity.

Namespace

Drupal\cms_content_sync\Entity

Code

public function getFieldHandler($entity_type_name, $bundle_name, $field_name) {
  $fieldPluginManager = \Drupal::service('plugin.manager.cms_content_sync_field_handler');
  $key = $entity_type_name . '-' . $bundle_name . '-' . $field_name;
  if (empty($this->sync_entities[$key])) {
    return null;
  }
  if (self::HANDLER_IGNORE == $this->sync_entities[$key]['handler']) {
    return null;
  }
  $entityFieldManager = \Drupal::service('entity_field.manager');
  $field_definition = $entityFieldManager
    ->getFieldDefinitions($entity_type_name, $bundle_name)[$field_name];
  return $fieldPluginManager
    ->createInstance($this->sync_entities[$key]['handler'], [
    'entity_type_name' => $entity_type_name,
    'bundle_name' => $bundle_name,
    'field_name' => $field_name,
    'field_definition' => $field_definition,
    'settings' => $this->sync_entities[$key],
    'sync' => $this,
  ]);
}