You are here

function simplemeta_get_page_meta in Simple Meta 8.2

Same name and namespace in other branches
  1. 8 simplemeta.module \simplemeta_get_page_meta()
  2. 6.2 simplemeta.module \simplemeta_get_page_meta()
  3. 7.2 simplemeta.module \simplemeta_get_page_meta()
  4. 7 simplemeta.module \simplemeta_get_page_meta()

Get SimpleMeta entity for a page, by path.

Parameters

string $path: Path of the page to get metadata for.

string $langcode: Language code to get metadata for.

bool $reset: TRUE to reset static cache.

Return value

\Drupal\simplemeta\Entity\SimplemetaEntity|false SimpleMeta entity if appropriate found, FALSE otherwise.

3 calls to simplemeta_get_page_meta()
simplemeta_page_attachments in ./simplemeta.module
Implements hook_page_attachments().
simplemeta_page_bottom in ./simplemeta.module
Implements hook_page_bottom().
simplemeta_preprocess_html in ./simplemeta.module
Implements hook_preprocess_HOOK().

File

./simplemeta.module, line 136
Contains simplemeta.module.

Code

function simplemeta_get_page_meta($path = NULL, $langcode = NULL, $reset = FALSE) {
  static $cache = [];
  if (!isset($path)) {
    $path = \Drupal::service('path.current')
      ->getPath();
  }
  if (!isset($cache[$path]) || $reset) {
    $parts = explode('/', $path);
    $ancestors = simplemeta_path_get_ancestors($parts);
    $cache[$path] = simplemeta_meta_load_by_path($ancestors, $langcode);
  }
  return $cache[$path];
}