You are here

public function FilebrowserManager::updateFilebrowser in Filebrowser 8.2

Same name and namespace in other branches
  1. 3.x src/FilebrowserManager.php \Drupal\filebrowser\FilebrowserManager::updateFilebrowser()

File

src/FilebrowserManager.php, line 377

Class

FilebrowserManager

Namespace

Drupal\filebrowser

Code

public function updateFilebrowser(Filebrowser $filebrowser, $mode) {

  /** @var \Drupal\Core\Database\Connection $connection */
  if (empty($filebrowser->nid)) {
    \Drupal::messenger()
      ->addError($this
      ->t('No filebrowser data available in node - remove exit'));
    exit;
  }
  $record['nid'] = $filebrowser->nid;
  $record['folder_path'] = $filebrowser->folderPath;
  $record['properties'] = serialize($filebrowser);
  if ($mode == 'insert') {
    $this->storage
      ->insert($record);
  }
  elseif ($mode == 'edit') {
    $this->storage
      ->update($record);
  }
}