You are here

function rdf_get_namespaces in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rdf/rdf.module \rdf_get_namespaces()
  2. 7 modules/rdf/rdf.module \rdf_get_namespaces()

Retrieves RDF namespaces.

Invokes hook_rdf_namespaces() and collects RDF namespaces from modules that implement it.

Related topics

4 calls to rdf_get_namespaces()
GetRdfNamespacesTest::testGetRdfNamespaces in core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
Tests getting RDF namespaces.
rdf_preprocess_html in core/modules/rdf/rdf.module
Implements hook_preprocess_HOOK() for HTML document templates.
Rss::render in core/modules/node/src/Plugin/views/row/Rss.php
Render a row object. This usually passes through to a theme template of some form, but not always.
RssFields::render in core/modules/views/src/Plugin/views/row/RssFields.php
Render a row object. This usually passes through to a theme template of some form, but not always.
2 string references to 'rdf_get_namespaces'
Rss::render in core/modules/node/src/Plugin/views/row/Rss.php
Render a row object. This usually passes through to a theme template of some form, but not always.
RssFields::render in core/modules/views/src/Plugin/views/row/RssFields.php
Render a row object. This usually passes through to a theme template of some form, but not always.

File

core/modules/rdf/rdf.module, line 112
Enables semantically enriched output for Drupal sites in the form of RDFa.

Code

function rdf_get_namespaces() {
  $namespaces = [];

  // In order to resolve duplicate namespaces by using the earliest defined
  // namespace, do not use \Drupal::moduleHandler()->invokeAll().
  foreach (\Drupal::moduleHandler()
    ->getImplementations('rdf_namespaces') as $module) {
    $function = $module . '_rdf_namespaces';
    foreach ($function() as $prefix => $namespace) {
      if (array_key_exists($prefix, $namespaces) && $namespace !== $namespaces[$prefix]) {
        throw new Exception("Tried to map '{$prefix}' to '{$namespace}', but '{$prefix}' is already mapped to '{$namespaces[$prefix]}'.");
      }
      else {
        $namespaces[$prefix] = $namespace;
      }
    }
  }
  return $namespaces;
}