function _contextual_id_to_links
Same name in other branches
- 9 core/modules/contextual/contextual.module \_contextual_id_to_links()
- 8.9.x core/modules/contextual/contextual.module \_contextual_id_to_links()
- 11.x core/modules/contextual/contextual.module \_contextual_id_to_links()
Unserializes the result of _contextual_links_to_id().
Note that $id is user input. Before calling this method the ID should be checked against the token stored in the 'data-contextual-token' attribute which is passed via the 'tokens' request parameter to \Drupal\contextual\ContextualController::render().
Parameters
string $id: A serialized representation of a #contextual_links property value array.
Return value
array The value for a #contextual_links property.
See also
\Drupal\contextual\ContextualController::render()
2 calls to _contextual_id_to_links()
- ContextualController::render in core/
modules/ contextual/ src/ ContextualController.php - Returns the requested rendered contextual links.
- ContextualUnitTest::testContextualIdToLinks in core/
modules/ contextual/ tests/ src/ Kernel/ ContextualUnitTest.php - Tests the conversion from contextual ID to links.
File
-
core/
modules/ contextual/ contextual.module, line 207
Code
function _contextual_id_to_links($id) {
$contextual_links = [];
$contexts = explode('|', $id);
foreach ($contexts as $context) {
[
$group,
$route_parameters_raw,
$metadata_raw,
] = explode(':', $context);
parse_str($route_parameters_raw, $route_parameters);
$metadata = [];
parse_str($metadata_raw, $metadata);
$contextual_links[$group] = [
'route_parameters' => $route_parameters,
'metadata' => $metadata,
];
}
return $contextual_links;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.