You are here

class FaviconController in Favicon 8

Favicon page controller.

Hierarchy

Expanded class hierarchy of FaviconController

File

lib/Drupal/favicon/Controller/FaviconController.php, line 17
Contains \Drupal\favicon\Controller\FaviconController.

Namespace

Drupal\favicon\Controller
View source
class FaviconController {

  /**
   * Generates an favicon page.
   */
  public function content() {

    // Add favicon.
    if (theme_get_setting('features.favicon')) {
      $favicon = theme_get_setting('favicon.url');
      $type = theme_get_setting('favicon.mimetype');
      $response = new Response();
      $request = \Drupal::request();
      $response->headers
        ->set('Content-Type', $type);
      $response->headers
        ->set('Expires', 0);
      $response
        ->setContent(file_get_contents($favicon));
      $response
        ->prepare($request);
      $response
        ->send();

      // We are done.
      exit;
    }
    throw new NotFoundHttpException();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FaviconController::content public function Generates an favicon page.