public function DatabaseFileUsageBackend::__construct in Drupal 8
Same name and namespace in other branches
- 9 core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php \Drupal\file\FileUsage\DatabaseFileUsageBackend::__construct()
Creates a FileUsageBase object.
@todo Update the docblock and make $config_factory required in https://www.drupal.org/project/drupal/issues/3070114 when the drupal:9.0.x branch is opened.
Parameters
\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory. This parameter is required as of drupal:8.4.0 and trigger a fatal error if not passed in drupal:9.0.0.
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\FileUsageCode
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;
}