public function FileUsageBase::add

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

Overrides FileUsageInterface::add

1 call to FileUsageBase::add()
DatabaseFileUsageBackend::add in drupal/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
Implements Drupal\file\FileUsage\FileUsageInterface::add().
1 method overrides FileUsageBase::add()
DatabaseFileUsageBackend::add in drupal/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
Implements Drupal\file\FileUsage\FileUsageInterface::add().

File

drupal/core/modules/file/lib/Drupal/file/FileUsage/FileUsageBase.php, line 20
Definition of Drupal\file\FileUsage\FileUsageBase.

Class

FileUsageBase
Defines the base class for database file usage backend.

Namespace

Drupal\file\FileUsage

Code

public function add(File $file, $module, $type, $id, $count = 1) {

  // Make sure that a used file is permament.
  if ($file->status != FILE_STATUS_PERMANENT) {
    $file->status = FILE_STATUS_PERMANENT;
    $file
      ->save();
  }
}