Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
varbase_layout_builder
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
varbase_layout_builder
Commits
724ff4bf
Commit
724ff4bf
authored
2 years ago
by
Rajab Natshah
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3349041
: Have the operation link back to work in Front-End and Back-End themes
parent
ee449317
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
varbase_layout_builder.module
+21
-24
21 additions, 24 deletions
varbase_layout_builder.module
with
21 additions
and
24 deletions
varbase_layout_builder.module
+
21
−
24
View file @
724ff4bf
...
...
@@ -17,31 +17,28 @@ use Drupal\Core\Asset\AttachedAssetsInterface;
* Implements hook_entity_operation().
*/
function
varbase_layout_builder_entity_operation
(
EntityInterface
$entity
)
{
if
(
\Drupal
::
service
(
'theme.manager'
)
->
getActiveTheme
()
->
getName
()
!==
\Drupal
::
config
(
'system.theme'
)
->
get
(
'admin'
))
{
$account
=
\Drupal
::
currentUser
();
$entity_type_id
=
$entity
->
getEntityTypeId
();
$route_name
=
"layout_builder.overrides.
$entity_type_id
.view"
;
$route_parameters
=
[
$entity_type_id
=>
$entity
->
id
(),
];
// If current user has access to route, then add the operation link. The
// access check will only return TRUE if the bundle is Layout Builder-
// enabled, overrides are allowed, and user has necessary permissions.
$access_manager
=
\Drupal
::
service
(
'access_manager'
);
if
(
!
$access_manager
->
checkNamedRoute
(
$route_name
,
$route_parameters
,
$account
))
{
return
;
}
$operations
[
'layout'
]
=
[
'title'
=>
t
(
'Layout'
),
'url'
=>
Url
::
fromRoute
(
$route_name
,
$route_parameters
),
'weight'
=>
50
,
];
return
$operations
;
$account
=
\Drupal
::
currentUser
();
$entity_type_id
=
$entity
->
getEntityTypeId
();
$route_name
=
"layout_builder.overrides.
$entity_type_id
.view"
;
$route_parameters
=
[
$entity_type_id
=>
$entity
->
id
(),
];
// If current user has access to route, then add the operation link. The
// access check will only return TRUE if the bundle is Layout Builder-
// enabled, overrides are allowed, and user has necessary permissions.
$access_manager
=
\Drupal
::
service
(
'access_manager'
);
if
(
!
$access_manager
->
checkNamedRoute
(
$route_name
,
$route_parameters
,
$account
))
{
return
;
}
return
;
$operations
[
'layout'
]
=
[
'title'
=>
t
(
'Layout'
),
'url'
=>
Url
::
fromRoute
(
$route_name
,
$route_parameters
),
'weight'
=>
50
,
];
return
$operations
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment