function IconFinder::getFileContents

Wrapper to the file_get_contents function.

This allow usage in extractor and easier unit test.

Parameters

string $uri: The URI to process, only local path allowed.

Return value

string|bool The file content.

Overrides IconFinderInterface::getFileContents

File

core/lib/Drupal/Core/Theme/Icon/IconFinder.php, line 114

Class

IconFinder
Icon finder to discover files under specific paths or URLs.

Namespace

Drupal\Core\Theme\Icon

Code

public function getFileContents(string $uri) : string|bool {
  $url = parse_url($uri);
  if (isset($url['scheme']) || isset($url['host'])) {
    return FALSE;
  }
  if (!file_exists($uri)) {
    return FALSE;
  }
  return file_get_contents($uri);
}

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