You are here

public function FileMetadataManager::uri in File metadata manager 8

Same name and namespace in other branches
  1. 8.2 src/FileMetadataManager.php \Drupal\file_mdm\FileMetadataManager::uri()

Returns a FileMetadata object for the URI, creating it if necessary.

Parameters

string $uri: The URI to a file.

Return value

\Drupal\file_mdm\FileMetadataInterface|null The FileMetadata object for the specified URI.

Overrides FileMetadataManagerInterface::uri

File

src/FileMetadataManager.php, line 115

Class

FileMetadataManager
A service class to provide file metadata.

Namespace

Drupal\file_mdm

Code

public function uri($uri) {
  if (!($hash = $this
    ->calculateHash($uri))) {
    return NULL;
  }
  if (!isset($this->files[$hash])) {
    $this->files[$hash] = new FileMetadata($this->pluginManager, $this->logger, $this->fileSystem, $uri, $hash);
  }
  return $this->files[$hash];
}