function FileReferenceUsage::__construct

Constructs a FileReferenceUsage object.

Parameters

string $entityTypeId: The entity type.

string $fieldName: The name of the field that contains the reference.

string|int|null $id: The entity ID.

int|string|null $revisionId: The revision ID.

File

core/modules/file/src/FileReferenceUsage.php, line 26

Class

FileReferenceUsage
Provides information which field on a given entity uses a file.

Namespace

Drupal\file

Code

public function __construct(public string $entityTypeId, public string $fieldName, public int|string|null $id = NULL, public int|string|null $revisionId = NULL) {
  if (is_null($id) && is_null($revisionId)) {
    throw new \InvalidArgumentException('$id and $revisionId cannot both be null.');
  }
}

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