Commit c9b2ff5e authored by webchick's avatar webchick

Issue #2301493 by alexpott: Fixed Typehint Drupal\file\File is does not exist.

parent 25afa810
This diff is collapsed.
......@@ -9,7 +9,7 @@
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
/**
* Defines the database file usage backend. This is the default Drupal backend.
......@@ -48,7 +48,7 @@ public function __construct(Connection $connection, $table = 'file_usage') {
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::add().
*/
public function add(File $file, $module, $type, $id, $count = 1) {
public function add(FileInterface $file, $module, $type, $id, $count = 1) {
$this->connection->merge($this->tableName)
->keys(array(
'fid' => $file->id(),
......@@ -66,7 +66,7 @@ public function add(File $file, $module, $type, $id, $count = 1) {
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::delete().
*/
public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1) {
public function delete(FileInterface $file, $module, $type = NULL, $id = NULL, $count = 1) {
// Delete rows that have a exact or less value to prevent empty rows.
$query = $this->connection->delete($this->tableName)
->condition('module', $module)
......@@ -101,7 +101,7 @@ public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::listUsage().
*/
public function listUsage(File $file) {
public function listUsage(FileInterface $file) {
$result = $this->connection->select($this->tableName, 'f')
->fields('f', array('module', 'type', 'id', 'count'))
->condition('fid', $file->id())
......
......@@ -7,7 +7,7 @@
namespace Drupal\file\FileUsage;
use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
/**
* Defines the base class for database file usage backend.
......@@ -17,7 +17,7 @@ abstract class FileUsageBase implements FileUsageInterface {
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::add().
*/
public function add(File $file, $module, $type, $id, $count = 1) {
public function add(FileInterface $file, $module, $type, $id, $count = 1) {
// Make sure that a used file is permanent.
if (!$file->isPermanent()) {
$file->setPermanent();
......@@ -28,7 +28,7 @@ public function add(File $file, $module, $type, $id, $count = 1) {
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::delete().
*/
public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1) {
public function delete(FileInterface $file, $module, $type = NULL, $id = NULL, $count = 1) {
// If there are no more remaining usages of this file, mark it as temporary,
// which result in a delete through system_cron().
$usage = \Drupal::service('file.usage')->listUsage($file);
......
......@@ -7,7 +7,7 @@
namespace Drupal\file\FileUsage;
use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
/**
* File usage backend interface.
......@@ -24,7 +24,7 @@ interface FileUsageInterface {
* - The User module associates an image with a user, so $type would be 'user'
* and the $id would be the user's uid.
*
* @param \Drupal\file\File $file
* @param \Drupal\file\FileInterface $file
* A file entity.
* @param string $module
* The name of the module using the file.
......@@ -35,12 +35,12 @@ interface FileUsageInterface {
* @param int $count
* (optional) The number of references to add to the object. Defaults to 1.
*/
public function add(File $file, $module, $type, $id, $count = 1);
public function add(FileInterface $file, $module, $type, $id, $count = 1);
/**
* Removes a record to indicate that a module is no longer using a file.
*
* @param \Drupal\file\File $file
* @param \Drupal\file\FileInterface $file
* A file entity.
* @param string $module
* The name of the module using the file.
......@@ -57,12 +57,12 @@ public function add(File $file, $module, $type, $id, $count = 1);
* to 1. Zero may be specified to delete all references to the file within a
* specific object.
*/
public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1);
public function delete(FileInterface $file, $module, $type = NULL, $id = NULL, $count = 1);
/**
* Determines where a file is used.
*
* @param \Drupal\file\File $file
* @param \Drupal\file\FileInterface $file
* A file entity.
*
* @return array
......@@ -71,5 +71,5 @@ public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1
* the third level contains the usage count.
*
*/
public function listUsage(File $file);
public function listUsage(FileInterface $file);
}
......@@ -7,7 +7,7 @@
namespace Drupal\service_provider_test;
use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
use Drupal\file\FileUsage\FileUsageBase;
class TestFileUsage extends FileUsageBase {
......@@ -15,18 +15,18 @@ class TestFileUsage extends FileUsageBase {
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::add().
*/
public function add(File $file, $module, $type, $id, $count = 1) {
public function add(FileInterface $file, $module, $type, $id, $count = 1) {
}
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::delete().
*/
public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1) {
public function delete(FileInterface $file, $module, $type = NULL, $id = NULL, $count = 1) {
}
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::listUsage().
*/
public function listUsage(File $file) {
public function listUsage(FileInterface $file) {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment