You are here

function _prevent_entity_export in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x cms_content_sync.module \_prevent_entity_export()
  2. 2.0.x cms_content_sync.module \_prevent_entity_export()

Prevent Export.

Only allow pushing of entities which have not been pulled before and do not have been configured as "forbid updating" or "allow overwrite".

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The current entity.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

2 calls to _prevent_entity_export()
cms_content_sync_entity_update in ./cms_content_sync.module
Push the entity 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

./cms_content_sync.module, line 515
Module file for cms_content_sync.

Code

function _prevent_entity_export(EntityInterface $entity) {
  $infos = EntityStatus::getInfosForEntity($entity
    ->getEntityTypeId(), $entity
    ->uuid());
  foreach ($infos as $info) {
    $entity_type_configuration = $info
      ->getFlow()
      ->getEntityTypeConfig($entity
      ->getEntityTypeId(), $entity
      ->bundle());
    if ($info
      ->getLastPull() && isset($entity_type_configuration['import_updates'])) {
      if ($entity_type_configuration['import_updates'] == PullIntent::PULL_UPDATE_FORCE_UNLESS_OVERRIDDEN || $entity_type_configuration['import_updates'] == PullIntent::PULL_UPDATE_FORCE_AND_FORBID_EDITING || $entity_type_configuration['import_updates'] == PullIntent::PULL_UPDATE_UNPUBLISHED) {
        return TRUE;
      }
    }
  }
  return FALSE;
}