Skip to content
Snippets Groups Projects
Commit b773deeb authored by jurgenhaas's avatar jurgenhaas
Browse files

Merge branch 'develop' into 'main'

Merging develop into main

See merge request !81
parents 38f9e085 0861e3d8
No related branches found
No related tags found
1 merge request!81Merging develop into main
Pipeline #946615 passed
......@@ -130,7 +130,7 @@
"#3355054 Default value for empty actions": "https://git.drupalcode.org/project/gin/-/merge_requests/246.diff"
},
"drupal/gin_toolbar": {
"#3319445 Permission check": "https://git.drupalcode.org/project/gin_toolbar/-/merge_requests/30.diff"
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch"
},
"drupal/glossify": {
"#3338553 PHP 8.1": "https://git.drupalcode.org/project/glossify/-/merge_requests/10.diff",
......
......@@ -134,7 +134,7 @@
"#3355054 Default value for empty actions": "https://git.drupalcode.org/project/gin/-/merge_requests/246.diff"
},
"drupal/gin_toolbar": {
"#3319445 Permission check": "https://git.drupalcode.org/project/gin_toolbar/-/merge_requests/30.diff"
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch"
},
"drupal/glossify": {
"#3338553 PHP 8.1": "https://git.drupalcode.org/project/glossify/-/merge_requests/10.diff",
......
diff --git a/gin_toolbar.module b/gin_toolbar.module
index 02bfce3568b53852a49092f0d6a6b3db89216a9d..1ced229a9910d12d0243ebd465f576e6c78361cf 100644
--- a/gin_toolbar.module
+++ b/gin_toolbar.module
@@ -8,6 +8,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Url;
use Drupal\gin_toolbar\Render\Element\GinToolbar;
use Drupal\gin\GinSettings;
use Drupal\gin\GinUserPicture;
@@ -194,8 +195,13 @@ function gin_toolbar_preprocess_toolbar(&$variables) {
$entity = \Drupal::request()->attributes->get($matches['entity_type_id']);
if ($entity instanceof EntityInterface && $entity->hasLinkTemplate('edit-form')) {
- $variables['entity_title'] = $entity->label();
- $variables['entity_edit_url'] = $entity->toUrl('edit-form');
+ if ($entity->access('update')) {
+ $variables['entity_title'] = $entity->label();
+ $variables['entity_edit_url'] = $entity->toUrl('edit-form');
+ }
+ elseif (Url::fromRoute('system.admin_content')->access(\Drupal::currentUser())) {
+ $variables['access_admin_content'] = TRUE;
+ }
}
}
}
diff --git a/templates/toolbar.html.twig b/templates/toolbar.html.twig
index e82bc1ceae19f14a3a7109a8d433e78dbf0d5ef3..5380e54f1899ef763f3036edef08f91e5b5d0a88 100644
--- a/templates/toolbar.html.twig
+++ b/templates/toolbar.html.twig
@@ -16,7 +16,7 @@
<li class="gin-breadcrumb__item">
{% if entity_edit_url and entity_title %}
<a class="gin-breadcrumb__link gin-back-to-admin" href="{{ entity_edit_url }}">{{ 'Edit %title'|t({ '%title': entity_title }) }}</a>
- {% else %}
+ {% elseif access_admin_content %}
<a class="gin-breadcrumb__link gin-back-to-admin" href="{{ path('system.admin_content') }}">{{ 'Back to Administration'|t }}</a>
{% endif %}
</li>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment