function DatabaseFileUsageBackend::__construct

Same name in other branches
  1. 9 core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php \Drupal\file\FileUsage\DatabaseFileUsageBackend::__construct()
  2. 10 core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php \Drupal\file\FileUsage\DatabaseFileUsageBackend::__construct()
  3. 11.x core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php \Drupal\file\FileUsage\DatabaseFileUsageBackend::__construct()

Overrides FileUsageBase::__construct

File

core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php, line 44

Class

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

Namespace

Drupal\file\FileUsage

Code

public function __construct($config_factory, $connection = NULL, $table = 'file_usage') {
    // @todo Remove below conditional when the drupal:9.0.x branch is opened.
    // @see https://www.drupal.org/project/drupal/issues/3070114
    if (!$config_factory instanceof ConfigFactoryInterface) {
        @trigger_error('Passing the database connection as the first argument to ' . __METHOD__ . ' is deprecated in drupal:8.8.0 and will throw a fatal error in drupal:9.0.0. Pass the config factory first. See https://www.drupal.org/node/3070148', E_USER_DEPRECATED);
        if (!$config_factory instanceof Connection) {
            throw new \InvalidArgumentException("The first argument to " . __METHOD__ . " should be an instance of \\Drupal\\Core\\Config\\ConfigFactoryInterface, " . gettype($config_factory) . " given.");
        }
        list($connection, $table, $config_factory) = array_pad(func_get_args(), 3, NULL);
        if (NULL === $table) {
            $table = 'file_usage';
        }
        if (!$config_factory instanceof ConfigFactoryInterface) {
            $config_factory = \Drupal::configFactory();
        }
    }
    parent::__construct($config_factory);
    $this->connection = $connection;
    $this->tableName = $table;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.