function rdf_get_namespaces

Same name in other branches
  1. 7.x modules/rdf/rdf.module \rdf_get_namespaces()
  2. 8.9.x core/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

5 calls to rdf_get_namespaces()
GetRdfNamespacesTest::testGetRdfNamespaces in core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
Tests getting RDF namespaces.
rdf_node_build_defaults_alter in core/modules/rdf/rdf.module
Implements hook_ENTITY_TYPE_build_defaults_alter().
rdf_preprocess_html in core/modules/rdf/rdf.module
Implements hook_preprocess_HOOK() for HTML document templates.
RssFields::render in core/modules/views/src/Plugin/views/row/RssFields.php
Renders a row object.
RssViewIntegrationTest::testRdfNamespacesAreAddedToRssViews in core/modules/rdf/tests/src/Functional/RssViewIntegrationTest.php
Tests that RSS views have RDF's XML namespaces defined.
1 string reference to 'rdf_get_namespaces'
RssFields::render in core/modules/views/src/Plugin/views/row/RssFields.php
Renders a row object.

File

core/modules/rdf/rdf.module, line 113

Code

function rdf_get_namespaces() {
    $namespaces = [];
    // In order to resolve duplicate namespaces by using the earliest defined
    // namespace, do not use \Drupal::moduleHandler()->invokeAll().
    \Drupal::moduleHandler()->invokeAllWith('rdf_namespaces', function (callable $hook, string $module) use (&$namespaces) {
        $namespacesFromHook = $hook();
        foreach ($namespacesFromHook 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.