contextual.module
Same filename and directory in other branches
File
-
core/
modules/ contextual/ contextual.module
View source
<?php
/**
* @file
*/
use Drupal\contextual\ContextualLinksSerializer;
/**
* Serializes #contextual_links property value array to a string.
*
* Examples:
* - node:node=1:langcode=en
* - views_ui_edit:view=frontpage:location=page&view_name=frontpage&view_display_id=page_1&langcode=en
* - menu:menu=tools:langcode=en|block:block=olivero.tools:langcode=en
*
* So, expressed in a pattern:
* <group>:<route parameters>:<metadata>
*
* The route parameters and options are encoded as query strings.
*
* @param array $contextual_links
* The $element['#contextual_links'] value for some render element.
*
* @return string
* A serialized representation of a #contextual_links property value array for
* use in a data- attribute.
*
* @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use
* \Drupal\contextual\ContextualLinksSerializer::linksToId() instead.
*
* @see https://www.drupal.org/node/3568088
*/
function _contextual_links_to_id($contextual_links) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use \\Drupal\\contextual\\ContextualLinksSerializer::linksToId() instead. See https://www.drupal.org/node/3568088', E_USER_DEPRECATED);
return \Drupal::service(ContextualLinksSerializer::class)->linksToId($contextual_links);
}
/**
* Unserializes the result of ContextualLinksSerializer::linksToId().
*
* 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().
*
* @param string $id
* A serialized representation of a #contextual_links property value array.
*
* @return array
* The value for a #contextual_links property.
*
* @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use
* \Drupal\contextual\ContextualLinksSerializer::idToLinks() instead.
*
* @see https://www.drupal.org/node/3568088
* @see \Drupal\contextual\ContextualLinksSerializer::linksToId()
* @see \Drupal\contextual\ContextualController::render()
*/
function _contextual_id_to_links($id) : array {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use \\Drupal\\contextual\\ContextualLinksSerializer::idToLinks() instead. See https://www.drupal.org/node/3568088', E_USER_DEPRECATED);
return \Drupal::service(ContextualLinksSerializer::class)->idToLinks($id);
}
Functions
| Title | Deprecated | Summary |
|---|---|---|
| _contextual_id_to_links | in drupal:11.4.0 and is removed from drupal:12.0.0. Use \Drupal\contextual\ContextualLinksSerializer::idToLinks() instead. |
Unserializes the result of ContextualLinksSerializer::linksToId(). |
| _contextual_links_to_id | in drupal:11.4.0 and is removed from drupal:12.0.0. Use \Drupal\contextual\ContextualLinksSerializer::linksToId() instead. |
Serializes #contextual_links property value array to a string. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.