You are here

public function MultiversionManager::allowToAlter in Multiversion 8.2

Same name and namespace in other branches
  1. 8 src/MultiversionManager.php \Drupal\multiversion\MultiversionManager::allowToAlter()

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type:

Return value

boolean

Overrides MultiversionManagerInterface::allowToAlter

File

src/MultiversionManager.php, line 195

Class

MultiversionManager

Namespace

Drupal\multiversion

Code

public function allowToAlter(EntityTypeInterface $entity_type) {
  $supported_entity_types = \Drupal::config('multiversion.settings')
    ->get('supported_entity_types') ?: [];
  $id = $entity_type
    ->id();
  $enable_active = self::enableIsActive();
  $disable_migration = self::disableIsActive();

  // Don't allow to alter entity type that is not supported.
  if (!in_array($id, $supported_entity_types)) {
    return FALSE;
  }

  // Don't allow to alter entity type that is in process to be disabled.
  if (is_array($disable_migration) && in_array($id, $disable_migration)) {
    return FALSE;
  }

  // Allow to alter entity type that is in process to be enabled.
  if (is_array($enable_active) && in_array($id, $enable_active)) {
    return TRUE;
  }
  return $this
    ->isEnabledEntityType($entity_type);
}