Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
entity
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
entity
Commits
9b5da5c9
Commit
9b5da5c9
authored
9 years ago
by
Daniel Wehner
Browse files
Options
Downloads
Patches
Plain Diff
Provide contextual links for all entity types
parent
ef00e241
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/EntityViewBuilder.php
+42
-0
42 additions, 0 deletions
src/EntityViewBuilder.php
with
42 additions
and
0 deletions
src/EntityViewBuilder.php
0 → 100644
+
42
−
0
View file @
9b5da5c9
<?php
/**
* @file
* Contains \Drupal\entity\EntityViewBuilder.
*/
namespace
Drupal\entity
;
use
Drupal\Core\Entity\ContentEntityInterface
;
use
Drupal\Core\Entity\Display\EntityViewDisplayInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Entity\EntityViewBuilder
as
CoreEntityViewBuilder
;
/**
* Provides a entity view builder with contextual links support
*/
class
EntityViewBuilder
extends
CoreEntityViewBuilder
{
/**
* {@inheritdoc}
*/
protected
function
alterBuild
(
array
&
$build
,
EntityInterface
$entity
,
EntityViewDisplayInterface
$display
,
$view_mode
)
{
$entity_type_id
=
$entity
->
getEntityTypeId
();
if
((
$entity
instanceof
ContentEntityInterface
&&
$entity
->
isDefaultRevision
())
||
!
$entity
->
getEntityType
()
->
isRevisionable
())
{
$build
[
'#contextual_links'
][
$entity_type_id
]
=
[
'route_parameters'
=>
[
$entity_type_id
=>
$entity
->
id
()
],
];
}
else
{
$build
[
'#contextual_links'
][
$entity_type_id
.
'_revision'
]
=
[
'route_parameters'
=>
[
$entity_type_id
=>
$entity
->
id
(),
$entity_type_id
.
'_revision'
=>
$entity
->
getRevisionId
(),
],
];
}
}
}
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