Commit 1202508f authored by gbyte's avatar gbyte Committed by Pawel G

Issue #3118054 by gbyte.co, jnycz: Notice: Undefined index: html_head_link in...

Issue #3118054 by gbyte.co, jnycz: Notice: Undefined index: html_head_link in simple_sitemap_page_attachments_alter()
parent 76e4f22b
......@@ -236,18 +236,22 @@ function simple_sitemap_menu_delete(MenuInterface $menu) {
* Implements hook_page_attachments_alter().
*/
function simple_sitemap_page_attachments_alter(array &$attachments) {
/** @var \Drupal\simple_sitemap\Simplesitemap $generator */
$generator = \Drupal::service('simple_sitemap.generator');
if ($generator->getSetting('disable_language_hreflang')) {
// @fixme https://www.drupal.org/project/drupal/issues/1255092
// Content Translation module normally adds identical hreflang tags, so
// executing its hook_page_attachments() implementation would be harmless,
// but if an entity page is configured as the front page, it attaches
// extraneous hreflang tags using the entity URL.
foreach ($attachments['#attached']['html_head_link'] as $key => $list) {
foreach ($list as $k => $element) {
if (!empty($element['hreflang']) && !empty($element['rel'])) {
unset($attachments['#attached']['html_head_link'][$key]);
if (!empty($attachments['#attached']['html_head_link'])) {
/** @var \Drupal\simple_sitemap\Simplesitemap $generator */
$generator = \Drupal::service('simple_sitemap.generator');
if ($generator->getSetting('disable_language_hreflang')) {
// @fixme https://www.drupal.org/project/drupal/issues/1255092
// Content Translation module normally adds identical hreflang tags, so
// executing its hook_page_attachments() implementation would be harmless,
// but if an entity page is configured as the front page, it attaches
// extraneous hreflang tags using the entity URL.
foreach ($attachments['#attached']['html_head_link'] as $key => $list) {
foreach ($list as $k => $element) {
if (!empty($element['hreflang']) && !empty($element['rel'])) {
unset($attachments['#attached']['html_head_link'][$key]);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment