You are here

public static function Flow::isLocalDeletionAllowed in CMS Content Sync 2.1.x

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

Check whether the local deletion of the given entity is allowed.

Return value

bool

2 calls to Flow::isLocalDeletionAllowed()
cms_content_sync_entity_delete in ./cms_content_sync.module
Push the entity deletion automatically if configured to do so.
cms_content_sync_form_alter in ./cms_content_sync.module
1) Make sure the user is informed that content will not only be deleted on this * instance but also on all connected instances if configured that way.

File

src/Entity/Flow.php, line 309

Class

Flow
Defines the "Content Sync - Flow" entity.

Namespace

Drupal\cms_content_sync\Entity

Code

public static function isLocalDeletionAllowed(EntityInterface $entity) {
  if (!$entity
    ->uuid()) {
    return true;
  }
  $entity_status = EntityStatus::getInfosForEntity($entity
    ->getEntityTypeId(), $entity
    ->uuid());
  foreach ($entity_status as $info) {
    if (!$info
      ->getLastPull() || $info
      ->isSourceEntity()) {
      continue;
    }
    $flow = $info
      ->getFlow();
    if (!$flow) {
      continue;
    }
    $config = $flow
      ->getController()
      ->getEntityTypeConfig($entity
      ->getEntityTypeId(), $entity
      ->bundle(), true);
    if (PullIntent::PULL_DISABLED === $config['import']) {
      continue;
    }
    if (!boolval($config['import_deletion_settings']['allow_local_deletion_of_import'])) {
      return false;
    }
  }
  return true;
}