function _contextual_links_to_id

Serializes #contextual_links property value array to a string.

Examples:

  • node:node:1:
  • views_ui:admin/structure/views/view:frontpage:location=page&view_name=frontpage&view_display_id=page_1
  • menu:admin/structure/menu/manage:tools:|block:admin/structure/block/manage:bartik.tools:

So, expressed in a pattern: <module name>:<parent path>:<path args>:<options>

The (dynamic) path args are joined with slashes. The options are encoded as a query string.

Parameters

array $contextual_links: The $element['#contextual_links'] value for some render element.

Return value

string A serialized representation of a #contextual_links property value array for use in a data- attribute.

3 calls to _contextual_links_to_id()
ContextualLinks::render in drupal/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
Render the contextual fields.
ContextualUnitTest::testContextualLinksToId in drupal/core/modules/contextual/lib/Drupal/contextual/Tests/ContextualUnitTest.php
Tests _contextual_links_to_id().
contextual_preprocess in drupal/core/modules/contextual/contextual.module
Implements hook_preprocess().

File

drupal/core/modules/contextual/contextual.module, line 318
Adds contextual links to perform actions related to elements on a page.

Code

function _contextual_links_to_id($contextual_links) {
  $id = '';
  foreach ($contextual_links as $module => $args) {
    $parent_path = $args[0];
    $path_args = implode('/', $args[1]);
    $metadata = drupal_http_build_query(isset($args[2]) ? $args[2] : array());
    if (drupal_strlen($id) > 0) {
      $id .= '|';
    }
    $id .= $module . ':' . $parent_path . ':' . $path_args . ':' . $metadata;
  }
  return $id;
}