You are here

public static function DefaultEntityReferenceHandler::supports in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 src/Plugin/cms_content_sync/field_handler/DefaultEntityReferenceHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultEntityReferenceHandler::supports()
  2. 2.0.x src/Plugin/cms_content_sync/field_handler/DefaultEntityReferenceHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultEntityReferenceHandler::supports()

Check if this handler supports the given field instance.

Parameters

string $entity_type:

string $bundle:

string $field_name:

Return value

bool

Overrides FieldHandlerInterface::supports

5 methods override DefaultEntityReferenceHandler::supports()
DefaultBricksHandler::supports in src/Plugin/cms_content_sync/field_handler/DefaultBricksHandler.php
Check if this handler supports the given field instance.
DefaultFieldCollectionHandler::supports in src/Plugin/cms_content_sync/field_handler/DefaultFieldCollectionHandler.php
Check if this handler supports the given field instance.
DefaultMenuLinkContentReferenceHandler::supports in src/Plugin/cms_content_sync/field_handler/DefaultMenuLinkContentReferenceHandler.php
Check if this handler supports the given field instance.
DefaultUserReferenceHandler::supports in src/Plugin/cms_content_sync/field_handler/DefaultUserReferenceHandler.php
Check if this handler supports the given field instance.
MergeableEntityReferenceHandler::supports in src/Plugin/cms_content_sync/field_handler/MergeableEntityReferenceHandler.php
Check if this handler supports the given field instance.

File

src/Plugin/cms_content_sync/field_handler/DefaultEntityReferenceHandler.php, line 32

Class

DefaultEntityReferenceHandler
Providing a minimalistic implementation for any field type.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler

Code

public static function supports($entity_type, $bundle, $field_name, FieldDefinitionInterface $field) {
  $supported = [
    'entity_reference',
    'entity_reference_revisions',
    'bibcite_contributor',
    'viewsreference',
    'dynamic_entity_reference',
  ];
  if (!in_array($field
    ->getType(), $supported)) {
    return false;
  }
  $types = EntityReferenceHandlerBase::getReferencedEntityTypesFromFieldDefinition($field);
  foreach ($types as $type) {
    if (in_array($type, [
      'user',
      'brick_type',
      'paragraph',
    ])) {
      return false;
    }
    if ('menu_link' == $field_name) {
      return false;
    }
    $referenced_entity_type = \Drupal::entityTypeManager()
      ->getStorage($type);
    if ($referenced_entity_type instanceof ConfigEntityStorage && !in_array($type, self::SUPPORTED_CONFIG_ENTITY_TYPES)) {
      return false;
    }
  }
  return true;
}