public function DatabaseFileUsageBackend::add

Implements Drupal\file\FileUsage\FileUsageInterface::add().

Overrides FileUsageBase::add

File

drupal/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php, line 51
Definition of Drupal\file\FileUsage\DatabaseFileUsageBackend.

Class

DatabaseFileUsageBackend
Defines the database file usage backend. This is the default Drupal backend.

Namespace

Drupal\file\FileUsage

Code

public function add(File $file, $module, $type, $id, $count = 1) {
  $this->connection
    ->merge($this->tableName)
    ->key(array(
    'fid' => $file->fid,
    'module' => $module,
    'type' => $type,
    'id' => $id,
  ))
    ->fields(array(
    'count' => $count,
  ))
    ->expression('count', 'count + :count', array(
    ':count' => $count,
  ))
    ->execute();
  parent::add($file, $module, $type, $id, $count);
}