You are here

public function ContentDatabaseStorage::cs_read 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_read()

File

src/Content/ContentDatabaseStorage.php, line 58

Class

ContentDatabaseStorage
Defines the Database storage.

Namespace

Drupal\content_sync\Content

Code

public function cs_read($name) {
  $data = FALSE;
  try {
    $raw = $this->connection
      ->query('SELECT data FROM {' . $this->connection
      ->escapeTable($this->table) . '} WHERE name = :name', [
      ':name' => $name,
    ], $this->options)
      ->fetchField();
    if ($raw !== FALSE) {
      $data = $this
        ->decode($raw);
    }
  } catch (\Exception $e) {

    // If we attempt a read without actually having the database or the table
    // available, just return FALSE so the caller can handle it.
  }
  return $data;
}