public function DefaultFavicons::routes in Responsive Favicons 8
1 string reference to 'DefaultFavicons::routes'
File
- src/
Routing/ DefaultFavicons.php, line 25 - Contains \Drupal\responsive_favicons\Routing\DefaultFavicons.
Class
- DefaultFavicons
- Class DefaultFavicons.
Namespace
Drupal\responsive_favicons\RoutingCode
public function routes() {
$route_collection = new RouteCollection();
$moduleHandler = \Drupal::service('module_handler');
// List of icons to redirect.
// Note, in order for these to work alter the fast404 pattern to allow these
// requests to hit Drupal. Please see the README for more information.
$icons = [
'/apple-touch-icon.png',
'/apple-touch-icon-precomposed.png',
'/browserconfig.xml',
];
// Try to avoid clashing with the favicon module.
if (!$moduleHandler
->moduleExists('favicon')) {
$icons[] = '/favicon.ico';
}
foreach ($icons as $icon) {
$route = new Route($icon, [
'_controller' => '\\Drupal\\responsive_favicons\\Controller\\GetFile::deliver',
'_title' => '',
], [
'_access' => 'TRUE',
]);
// Add the route under a unique key.
$key = preg_replace("/[^A-Za-z]/", '', $icon);
$route_collection
->add('responsive_favicons.' . $key, $route);
}
return $route_collection;
}