You are here

public function DefaultNodeHandler::ignorePush in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 src/Plugin/cms_content_sync/entity_handler/DefaultNodeHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultNodeHandler::ignorePush()
  2. 2.0.x src/Plugin/cms_content_sync/entity_handler/DefaultNodeHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultNodeHandler::ignorePush()

Check if the entity should not be ignored from the push.

Parameters

\Drupal\cms_content_sync\SyncIntent $intent: The Sync Core Request

\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity that could be ignored

string $reason: The reason why the entity should be ignored from the push

string $action: The action to apply

Return value

bool Whether or not to ignore this push request

Throws

\Exception

Overrides EntityHandlerBase::ignorePush

File

src/Plugin/cms_content_sync/entity_handler/DefaultNodeHandler.php, line 142

Class

DefaultNodeHandler
Class DefaultNodeHandler, providing proper handling for published/unpublished content.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler

Code

public function ignorePush(PushIntent $intent) {

  /**
   * @var \Drupal\node\NodeInterface $entity
   */
  $entity = $intent
    ->getEntity();
  $node_storage = \Drupal::entityTypeManager()
    ->getStorage('node');
  $node = $node_storage
    ->load($entity
    ->id());
  if (!$entity
    ->isPublished() && $this->settings['handler_settings']['ignore_unpublished']) {
    if (!$this->settings['handler_settings']['allow_explicit_unpublishing'] || $node
      ->isPublished() || $entity
      ->getRevisionId() == $node
      ->getRevisionId() && !$intent
      ->getEntityStatus()
      ->getLastPush()) {
      return true;
    }
  }
  return parent::ignorePush($intent);
}