You are here

protected function ContentDatabaseStorage::cs_doWrite in Content Synchronization 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Content/ContentDatabaseStorage.php \Drupal\content_sync\Content\ContentDatabaseStorage::cs_doWrite()

Helper method so we can re-try a write.

Parameters

string $name: The content name.

string $data: The content data, already dumped to a string.

string $collection: The content collection name, entity type + bundle.

Return value

bool

1 call to ContentDatabaseStorage::cs_doWrite()
ContentDatabaseStorage::cs_write in src/Content/ContentDatabaseStorage.php

File

src/Content/ContentDatabaseStorage.php, line 43

Class

ContentDatabaseStorage
Defines the Database storage.

Namespace

Drupal\content_sync\Content

Code

protected function cs_doWrite($name, $data, $collection) {
  $options = [
    'return' => Database::RETURN_AFFECTED,
  ] + $this->options;
  $this->connection
    ->delete($this->table, $options)
    ->condition('name', $name)
    ->execute();
  return (bool) $this->connection
    ->merge($this->table, $options)
    ->keys([
    'collection',
    'name',
  ], [
    $collection,
    $name,
  ])
    ->fields([
    'data' => $data,
  ])
    ->execute();
}