You are here

public function MetatagManager::getSpecialMetatags in Metatag 8

Returns special meta tags.

Return value

\Drupal\metatag\Entity\MetatagDefaults|null The defaults for this page, if it's a special page.

1 call to MetatagManager::getSpecialMetatags()
MetatagManager::getDefaultMetatags in src/MetatagManager.php
Returns default meta tags for an entity.

File

src/MetatagManager.php, line 430

Class

MetatagManager
Class MetatagManager.

Namespace

Drupal\metatag

Code

public function getSpecialMetatags() {
  $metatags = NULL;
  if (\Drupal::service('path.matcher')
    ->isFrontPage()) {
    $metatags = $this->metatagDefaults
      ->load('front');
  }
  elseif (\Drupal::service('current_route_match')
    ->getRouteName() == 'system.403') {
    $metatags = $this->metatagDefaults
      ->load('403');
  }
  elseif (\Drupal::service('current_route_match')
    ->getRouteName() == 'system.404') {
    $metatags = $this->metatagDefaults
      ->load('404');
  }
  if ($metatags && !$metatags
    ->status()) {

    // Do not return disabled special metatags.
    return NULL;
  }
  return $metatags;
}