You are here

public function ContentDatabaseStorage::cs_write 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_write()

File

src/Content/ContentDatabaseStorage.php, line 16

Class

ContentDatabaseStorage
Defines the Database storage.

Namespace

Drupal\content_sync\Content

Code

public function cs_write($name, array $data, $collection) {
  $data = $this
    ->encode($data);
  try {
    return $this
      ->cs_doWrite($name, $data, $collection);
  } catch (\Exception $e) {

    // If there was an exception, try to create the table.
    if ($this
      ->ensureTableExists()) {
      return $this
        ->cs_doWrite($name, $data, $collection);
    }

    // Some other failure that we can not recover from.
    throw $e;
  }
}