DefaultFavicons.php in Responsive Favicons 8
File
src/Routing/DefaultFavicons.php
View source
<?php
namespace Drupal\responsive_favicons\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
class DefaultFavicons {
public function routes() {
$route_collection = new RouteCollection();
$moduleHandler = \Drupal::service('module_handler');
$icons = [
'/apple-touch-icon.png',
'/apple-touch-icon-precomposed.png',
'/browserconfig.xml',
];
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',
]);
$key = preg_replace("/[^A-Za-z]/", '', $icon);
$route_collection
->add('responsive_favicons.' . $key, $route);
}
return $route_collection;
}
}