Skip to content
Snippets Groups Projects

Issue #3431657: Replace the "displayfields.token" service with a protected class method

3 files
+ 30
116
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -72,7 +72,7 @@ public function createForm($form, FormStateInterface $form_state, $parents = [])
];
// Add the token browser at the bottom.
$form['token'] = \Drupal::service('displayfields.token')->tokenBrowser();
$form['token'] = $this->tokenBrowser();
return $form;
}
@@ -217,10 +217,37 @@ protected function fieldRowSettingsForm($form, FormStateInterface $form_state, $
'#default_value' => $data,
];
// Add the token browser at the top.
$elements['token'] = \Drupal::service('displayfields.token')->tokenBrowser();
$elements['token'] = $this->tokenBrowser();
return $elements;
}
/**
* Gets the token browser.
*
* @return array
* The render array for the token browser, if the Token module is
* installed, or for a short description about how to use tokens.
*/
protected function tokenBrowser() {
$element['intro_text'] = [
'#markup' => '<p>' . t("Configure the tokens below. Use tokens to avoid redundant meta data and search engine penalization. For example, a 'keyword' value of 'example' will be shown on all content using this configuration, whereas using the [node:field_keywords] automatically inserts the 'keywords' values from the node.") . '</p>',
];
if (\Drupal::moduleHandler()->moduleExists('token')) {
$element['tokens'] = [
'#theme' => 'token_tree_link',
'#token_types' => 'all',
'#global_types' => TRUE,
'#click_insert' => TRUE,
'#show_restricted' => FALSE,
'#recursion_limit' => 3,
'#text' => t('Browse available tokens'),
];
}
return $element;
}
/**
* Builds the field row settings summary markup.
*
@@ -408,7 +435,7 @@ public function getFieldBuild($entities, $display_field, $display_settings, $par
/**
* Gets the current view mode from the current display.
*
*
* @return string
*/
protected function getCurrentViewMode() {
Loading