You are here

public function ExportEntity::addEntity in Content Synchronizer 8

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

Add entity to the export entities list.

Parameters

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

File

src/Entity/ExportEntity.php, line 220

Class

ExportEntity
Defines the Export entity entity.

Namespace

Drupal\content_synchronizer\Entity

Code

public function addEntity(Entity $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();
  }
}