You are here

private function GetFile::getFile in Responsive Favicons 8

Creates a file object for the requested icon path.

Parameters

string $file_path: the icon filename.

Return value

object a file object.

1 call to GetFile::getFile()
GetFile::deliver in src/Controller/GetFile.php
Attempts to send the raw file back in the response.

File

src/Controller/GetFile.php, line 25

Class

GetFile
Class GetFile.

Namespace

Drupal\responsive_favicons\Controller

Code

private function getFile($file_path) {
  $config = $this
    ->config('responsive_favicons.settings');
  if ($config
    ->get('path_type') == 'upload') {
    $uri = 'public://' . $config
      ->get('path') . $file_path;
  }
  else {
    $uri = DRUPAL_ROOT . $config
      ->get('path') . $file_path;
  }
  $file = new \stdClass();
  $file->uri = $uri;
  $file->filemime = \Drupal::service('file.mime_type.guesser')
    ->guess($uri);
  $file->filesize = @filesize($uri);
  return $file;
}