Skip to content
Snippets Groups Projects
Commit 3039fe66 authored by Kostia Bohach's avatar Kostia Bohach
Browse files

Issue #3425639: Content type edit link does not show with Gin theme

parent 61e760cb
No related branches found
Tags 2.0.4
1 merge request!5Issue #3425639: Content type edit link does not show with Gin theme
Pipeline #115367 passed
......@@ -5,9 +5,9 @@
* This is the module to create a drop-down menu for the core toolbar.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\entity_reference_edit_link\Plugin\Field\FieldWidget\EntityReferenceEditLinkAutocompleteTagsWidget;
use Drupal\entity_reference_edit_link\Plugin\Field\FieldWidget\EntityReferenceEditLinkAutocompleteWidget;
......@@ -126,13 +126,46 @@ function entity_reference_edit_link_form_alter(&$form, FormStateInterface $form_
if (!$node) {
return;
}
$form['#title'] = entity_reference_edit_link_build_entity_type_link($node);
}
/**
* Implements hook_preprocess_HOOK().
*/
function entity_reference_edit_link_preprocess_page_title(&$variables) {
// To handle Gin theme node edit page structure.
$node = \Drupal::routeMatch()->getParameter('node');
// Only for the node edit pages.
if (!$node || \Drupal::routeMatch()->getRouteName() != 'entity.node.edit_form') {
return;
}
$variables['title'] = entity_reference_edit_link_build_entity_type_link($node);
}
/**
* Implements hook_theme_registry_alter().
*/
function entity_reference_edit_link_theme_registry_alter(&$theme_registry) {
// To run module hook function before Gin theme functions.
foreach ($theme_registry['page_title']['preprocess functions'] as $key => $value) {
if ($value == 'entity_reference_edit_link_preprocess_page_title') {
unset($theme_registry['page_title']['preprocess functions'][$key]);
$theme_registry['page_title']['preprocess functions'][] = $value;
}
}
}
/**
* Implements hook_entity().
*/
function entity_reference_edit_link_build_entity_type_link($node) {
$url = Url::fromRoute("entity.{$node->getEntityTypeId()}.field_ui_fields", [
'node_type' => $node->bundle(),
],
[
'attributes' => ['target' => '_blank'],
]);
$form['#title'] = t('<em>Edit @type</em> @title', [
[
'attributes' => ['target' => '_blank'],
]);
return t('<em>Edit @type</em> @title', [
'@type' => Link::fromTextAndUrl(node_get_type_label($node), $url)->toString(),
'@title' => $node->label(),
]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment