Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wse
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
wse
Merge requests
!96
Resolve
#3490853
"Fix revision overview"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve
#3490853
"Fix revision overview"
issue/wse-3490853:3490853-fix-revision-overview
into
2.0.x
Overview
0
Commits
2
Pipelines
3
Changes
7
Merged
Andrei Mateescu
requested to merge
issue/wse-3490853:3490853-fix-revision-overview
into
2.0.x
3 months ago
Overview
0
Commits
2
Pipelines
3
Changes
7
Expand
Closes
#3490853
0
0
Merge request reports
Compare
2.0.x
version 2
f1f1ba71
3 months ago
version 1
662c9fc5
3 months ago
2.0.x (base)
and
latest version
latest version
f1f1ba71
2 commits,
3 months ago
version 2
f1f1ba71
2 commits,
3 months ago
version 1
662c9fc5
1 commit,
3 months ago
7 files
+
106
−
246
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
src/Controller/VersionHistoryTrait.php
0 → 100644
+
56
−
0
Options
<?php
namespace
Drupal\wse\Controller
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Render\Element
;
/**
* Provides helper methods for the revision overview controllers.
*/
trait
VersionHistoryTrait
{
/**
* Adds information about each revision's workspace.
*
* @param array $build
* The render array from the version history controller.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
* @param array|null $revisions
* (optional) An array of revisions that are displayed in the table.
*/
protected
function
alterRevisionsTable
(
array
&
$build
,
EntityInterface
$entity
,
?array
$revisions
=
NULL
):
void
{
// Add a column to show the workspace in which a revision has been created.
$keys
=
Element
::
children
(
$build
);
if
(
!
$revisions
)
{
$revisions
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
$entity
->
getEntityTypeId
())
->
loadMultipleRevisions
(
$keys
);
}
$field_name
=
$entity
->
getEntityType
()
->
getRevisionMetadataKey
(
'workspace'
);
foreach
(
$keys
as
$key
)
{
$revision
=
current
(
$revisions
);
$label
=
''
;
if
(
$workspace
=
$revision
->
get
(
$field_name
)
->
entity
)
{
$label
=
$workspace
->
access
(
'view label'
)
?
$workspace
->
label
()
:
$this
->
t
(
'- Restricted access -'
);
}
// Insert the workspace label column.
if
(
isset
(
$build
[
$key
][
'data'
]))
{
$build
[
$key
][
'data'
][
'workspace'
]
=
[
'data'
=>
$label
];
}
elseif
(
isset
(
$build
[
$key
][
0
]))
{
$build
[
$key
][
'workspace'
]
=
[
'data'
=>
$label
];
}
else
{
$build
[
$key
][
'workspace'
]
=
[
'#markup'
=>
$label
];
}
next
(
$revisions
);
}
}
}
Loading