You are here

public static function DefaultContentEntityHandler::supports in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/cms_content_sync/entity_handler/DefaultContentEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultContentEntityHandler::supports()
  2. 2.1.x src/Plugin/cms_content_sync/entity_handler/DefaultContentEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultContentEntityHandler::supports()

Check if this handler supports the given entity type.

Parameters

string $entity_type:

string $bundle:

Return value

bool

Overrides EntityHandlerInterface::supports

File

src/Plugin/cms_content_sync/entity_handler/DefaultContentEntityHandler.php, line 23

Class

DefaultContentEntityHandler
Class DefaultContentEntityHandler, providing a minimalistic implementation for any content entity type.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler

Code

public static function supports($entity_type, $bundle) {

  // Whitelist supported entity types.
  $entity_types = [
    'block_content',
    'config_pages',
    'paragraph',
    'paragraphs_library_item',
    'bibcite_contributor',
    'bibcite_reference',
    'bibcite_keyword',
    'redirect',
  ];
  $moduleHandler = \Drupal::service('module_handler');
  $eck_exists = $moduleHandler
    ->moduleExists('eck');
  if ($eck_exists) {
    $eck_entity_type = \Drupal::entityTypeManager()
      ->getStorage('eck_entity_type')
      ->load($entity_type);
    if (!empty($eck_entity_type)) {
      return true;
    }
  }
  return in_array($entity_type, $entity_types);
}