function 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 drupal/core/modules/rdf/lib/Drupal/rdf/Tests/GetRdfNamespacesTest.php
Tests getting RDF namespaces.
rdf_preprocess_html in drupal/core/modules/rdf/rdf.module
Implements hook_preprocess_HOOK() for html.tpl.php.
Rss::render in drupal/core/modules/node/lib/Drupal/node/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 drupal/core/modules/views/lib/Drupal/views/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 drupal/core/modules/node/lib/Drupal/node/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 drupal/core/modules/views/lib/Drupal/views/Plugin/views/row/RssFields.php
Render a row object. This usually passes through to a theme template of some form, but not always.

File

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

Code

function rdf_get_namespaces() {
  $rdf_namespaces = module_invoke_all('rdf_namespaces');

  // module_invoke_all() uses array_merge_recursive() which might return nested
  // arrays if several modules redefine the same prefix multiple times. We need
  // to ensure the array of namespaces is flat and only contains strings as
  // URIs.
  foreach ($rdf_namespaces as $prefix => $uri) {
    if (is_array($uri)) {
      if (count(array_unique($uri)) == 1) {

        // All namespaces declared for this prefix are the same, merge them all
        // into a single namespace.
        $rdf_namespaces[$prefix] = $uri[0];
      }
      else {

        // There are conflicting namespaces for this prefix, do not include
        // duplicates in order to avoid asserting any inaccurate RDF
        // statements.
        unset($rdf_namespaces[$prefix]);
      }
    }
  }
  return $rdf_namespaces;
}