Skip to content

Commit

Permalink
Issue #11: Used default theme favicon instead of administrative theme…
Browse files Browse the repository at this point in the history
… favicon.
  • Loading branch information
lexhouk committed Jun 20, 2018
1 parent 05c1651 commit 4a9d9ac
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions d8.profile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Basis for the site on Drupal 8.
*/

use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Database\Database;
use Drupal\Core\Url;
Expand Down Expand Up @@ -39,3 +40,24 @@ function _d8_user_login_form_submit(array &$form, FormStateInterface $form_state
$form_state->setRedirectUrl(Url::fromUserInput($path));
}
}

/**
* Implements hook_page_attachments_alter().
*/
function d8_page_attachments_alter(array &$attachments) {
$theme = \Drupal::config('system.theme')->get('default');

if ($theme != \Drupal::theme()->getActiveTheme()->getName() && theme_get_setting('features.favicon') && !empty($attachments['#attached']['html_head_link']) && is_array($attachments['#attached']['html_head_link'])) {
foreach ($attachments['#attached']['html_head_link'] as &$links) {
if (!empty($links) && is_array($links)) {
foreach ($links as &$link) {
if (!empty($link) && is_array($link) && !empty($link['rel']) && $link['rel'] == 'shortcut icon' && !empty($link['type']) && $link['type'] == theme_get_setting('favicon.mimetype') && !empty($link['href'])) {
$favicon = theme_get_setting('favicon.url', $theme);
$link['href'] = UrlHelper::stripDangerousProtocols($favicon);
return;
}
}
}
}
}
}

0 comments on commit 4a9d9ac

Please sign in to comment.