You are here

public function PushEntities::addEntity in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Controller/PushEntities.php \Drupal\cms_content_sync\Controller\PushEntities::addEntity()
  2. 2.0.x src/Controller/PushEntities.php \Drupal\cms_content_sync\Controller\PushEntities::addEntity()

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

Return value

$this

File

src/Controller/PushEntities.php, line 145

Class

PushEntities
Pull controller.

Namespace

Drupal\cms_content_sync\Controller

Code

public function addEntity($entity) {
  $flows = PushIntent::getFlowsForEntity($entity, PushIntent::PUSH_FORCED, SyncIntent::ACTION_CREATE);
  if (!count($flows)) {
    $this->_skippedNoFlow[] = $entity;
    return $this;
  }
  $flow_id = $flows[0]
    ->id();

  /**
   * @var \Drupal\cms_content_sync\Entity\EntityStatus[] $entity_status
   */
  $entity_status = EntityStatus::getInfosForEntity($entity
    ->getEntityTypeId(), $entity
    ->uuid(), [
    'flow' => $flow_id,
  ]);
  if ($this->_skipUnpushed) {
    if (!count($entity_status) || !$entity_status[0]
      ->getLastPush()) {
      $this->_skippedUnpushed[] = $entity;
      return $this;
    }
  }
  $this
    ->add($flow_id, $entity
    ->getEntityTypeId(), $entity
    ->id());
  return $this;
}