/**
  * Enhances a page object based on a render array.
  *
  * @param \Drupal\Core\Page\HtmlPage $page
  *   The page object to enhance.
  * @param array $page_array
  *   The page array to extract onto the page object.
  *
  * @return \Drupal\Core\Page\HtmlPage
  *   The modified page object.
  */
 public function preparePage(HtmlPage $page, &$page_array)
 {
     $page_array['#page'] = $page;
     // HTML element attributes.
     $language_interface = $this->languageManager->getCurrentLanguage();
     $html_attributes = $page->getHtmlAttributes();
     $html_attributes['lang'] = $language_interface->id;
     $html_attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
     $this->setDefaultMetaTags($page);
     // @todo: collect feed links from #attached rather than a static once
     // http://drupal.org/node/2256365 is completed.
     foreach (drupal_get_feeds() as $feed) {
         // Force the URL to be absolute, for consistency with other <link> tags
         // output by Drupal.
         $link = new FeedLinkElement($feed['title'], url($feed['url'], array('absolute' => TRUE)));
         $page->addLinkElement($link);
     }
     return $page;
 }
 /**
  * Enhances a page object based on a render array.
  *
  * @param \Drupal\Core\Page\HtmlPage $page
  *   The page object to enhance.
  * @param array $page_array
  *   The page array to extract onto the page object.
  *
  * @return \Drupal\Core\Page\HtmlPage
  *   The modified page object.
  */
 public function preparePage(HtmlPage $page, &$page_array)
 {
     $page_array['#page'] = $page;
     // HTML element attributes.
     $language_interface = $this->languageManager->getCurrentLanguage();
     $html_attributes = $page->getHtmlAttributes();
     $html_attributes['lang'] = $language_interface->getId();
     $html_attributes['dir'] = $language_interface->getDirection();
     $this->setDefaultMetaTags($page);
     // Add libraries and CSS used by this theme.
     $active_theme = \Drupal::theme()->getActiveTheme();
     foreach ($active_theme->getLibraries() as $library) {
         $page_array['#attached']['library'][] = $library;
     }
     foreach ($active_theme->getStyleSheets() as $media => $stylesheets) {
         foreach ($stylesheets as $stylesheet) {
             $page_array['#attached']['css'][$stylesheet] = array('group' => CSS_AGGREGATE_THEME, 'every_page' => TRUE, 'media' => $media);
         }
     }
     return $page;
 }
 /**
  * Enhances a page object based on a render array.
  *
  * @param \Drupal\Core\Page\HtmlPage $page
  *   The page object to enhance.
  * @param array $page_array
  *   The page array to extract onto the page object.
  *
  * @return \Drupal\Core\Page\HtmlPage
  *   The modified page object.
  */
 public function preparePage(HtmlPage $page, &$page_array)
 {
     $page_array['#page'] = $page;
     // HTML element attributes.
     $language_interface = $this->languageManager->getCurrentLanguage();
     $html_attributes = $page->getHtmlAttributes();
     $html_attributes['lang'] = $language_interface->getId();
     $html_attributes['dir'] = $language_interface->getDirection();
     $this->setDefaultMetaTags($page);
     // @todo: collect feed links from #attached rather than a static once
     // http://drupal.org/node/2256365 is completed.
     foreach (drupal_get_feeds() as $feed) {
         // Force the URL to be absolute, for consistency with other <link> tags
         // output by Drupal.
         $link = new FeedLinkElement($feed['title'], _url($feed['url'], array('absolute' => TRUE)));
         $page->addLinkElement($link);
     }
     // Add libraries and CSS used by this theme.
     $active_theme = \Drupal::theme()->getActiveTheme();
     foreach ($active_theme->getLibraries() as $library) {
         $page_array['#attached']['library'][] = $library;
     }
     foreach ($active_theme->getStyleSheets() as $media => $stylesheets) {
         foreach ($stylesheets as $stylesheet) {
             $page_array['#attached']['css'][$stylesheet] = array('group' => CSS_AGGREGATE_THEME, 'every_page' => TRUE, 'media' => $media);
         }
     }
     return $page;
 }