You are here

function responsive_favicons_load_all_icons in Responsive Favicons 8

Same name and namespace in other branches
  1. 7 responsive_favicons.module \responsive_favicons_load_all_icons()

Load the responsive favicons that are valid.

2 calls to responsive_favicons_load_all_icons()
responsive_favicons_page_attachments in ./responsive_favicons.module
Implements hook_page_attachments().
responsive_favicons_requirements in ./responsive_favicons.install
Implements hook_requirements().

File

./responsive_favicons.module, line 74
Contains responsive_favicons.module.

Code

function responsive_favicons_load_all_icons() {
  $icons =& drupal_static(__FUNCTION__);
  if (!isset($icons)) {
    $config = \Drupal::config('responsive_favicons.settings');
    $cid = 'responsive_favicons:icons';
    if ($cached = \Drupal::cache()
      ->get($cid)) {
      $icons = $cached->data;
    }
    else {
      $tags = $config
        ->get('tags');
      if (empty($tags)) {
        $icons = [
          'found' => [],
          'missing' => [],
        ];
      }
      else {
        $html = implode(PHP_EOL, $tags);
        $icons = _responsive_favicons_validate_tags($html);
        if (empty($icons['missing'])) {
          \Drupal::cache()
            ->set($cid, $icons);
        }
      }
    }
  }
  return $icons;
}