You are here

public function ExportEntity::addEntity in Content Synchronizer 3.x

Same name and namespace in other branches
  1. 8.2 src/Entity/ExportEntity.php \Drupal\content_synchronizer\Entity\ExportEntity::addEntity()
  2. 8 src/Entity/ExportEntity.php \Drupal\content_synchronizer\Entity\ExportEntity::addEntity()

Add entity to the export entities list.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to add.

File

src/Entity/ExportEntity.php, line 225

Class

ExportEntity
Defines the Export entity entity.

Namespace

Drupal\content_synchronizer\Entity

Code

public function addEntity(EntityInterface $entity) {
  if (!$this
    ->hasEntity($entity)) {
    $data = [
      self::FIELD_ENTITY_ID => $entity
        ->id(),
      self::FIELD_ENTITY_TYPE => $entity
        ->getEntityTypeId(),
      self::FIELD_EXPORT_ID => $this
        ->id(),
    ];
    \Drupal::database()
      ->insert(self::TABLE_ITEMS)
      ->fields(array_keys($data), $data)
      ->execute();
  }
}