Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
diff
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
diff
Commits
6be5078f
Commit
6be5078f
authored
7 months ago
by
Lucas Hedding
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3293558
by heddn, amateescu, s_leu: Allow usage of revision comparison inside workspaces
parent
1fe91367
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!103
Resolve #3293558 "Workspaces support"
Pipeline
#369236
failed
6 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
phpstan-baseline.neon
+0
-20
0 additions, 20 deletions
phpstan-baseline.neon
src/Form/RevisionOverviewForm.php
+28
-16
28 additions, 16 deletions
src/Form/RevisionOverviewForm.php
with
28 additions
and
36 deletions
phpstan-baseline.neon
+
0
−
20
View file @
6be5078f
...
@@ -310,26 +310,6 @@ parameters:
...
@@ -310,26 +310,6 @@ parameters:
count: 1
count: 1
path: src/Form/RevisionOverviewForm.php
path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#2 \\$return_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, int given\\.$#"
count: 4
path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#3 \\$default_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, false given\\.$#"
count: 2
path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#3 \\$default_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, int given\\.$#"
count: 1
path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#3 \\$default_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, int\\|false given\\.$#"
count: 1
path: src/Form/RevisionOverviewForm.php
-
-
message: "#^Parameter \\#4 \\$previous_revision of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildRevision\\(\\) expects Drupal\\\\Core\\\\Entity\\\\ContentEntityInterface\\|null, Drupal\\\\Core\\\\Entity\\\\RevisionableInterface\\|null given\\.$#"
message: "#^Parameter \\#4 \\$previous_revision of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildRevision\\(\\) expects Drupal\\\\Core\\\\Entity\\\\ContentEntityInterface\\|null, Drupal\\\\Core\\\\Entity\\\\RevisionableInterface\\|null given\\.$#"
count: 2
count: 2
...
...
This diff is collapsed.
Click to expand it.
src/Form/RevisionOverviewForm.php
+
28
−
16
View file @
6be5078f
...
@@ -19,6 +19,7 @@ use Drupal\Core\Session\AccountInterface;
...
@@ -19,6 +19,7 @@ use Drupal\Core\Session\AccountInterface;
use
Drupal\Core\Url
;
use
Drupal\Core\Url
;
use
Drupal\diff\DiffEntityComparison
;
use
Drupal\diff\DiffEntityComparison
;
use
Drupal\diff\DiffLayoutManager
;
use
Drupal\diff\DiffLayoutManager
;
use
Drupal\node\NodeInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
/**
...
@@ -78,20 +79,7 @@ class RevisionOverviewForm extends FormBase {
...
@@ -78,20 +79,7 @@ class RevisionOverviewForm extends FormBase {
$node_storage
=
$this
->
entityTypeManager
->
getStorage
(
'node'
);
$node_storage
=
$this
->
entityTypeManager
->
getStorage
(
'node'
);
$type
=
$node
->
getType
();
$type
=
$node
->
getType
();
$pagerLimit
=
$this
->
config
->
get
(
'general_settings.revision_pager_limit'
);
$vids
=
$this
->
getRevisionIds
(
$node
);
$query
=
$this
->
entityTypeManager
->
getStorage
(
'node'
)
->
getQuery
()
->
condition
(
$node
->
getEntityType
()
->
getKey
(
'id'
),
$node
->
id
())
->
pager
(
$pagerLimit
)
->
allRevisions
()
->
sort
(
$node
->
getEntityType
()
->
getKey
(
'revision'
),
'DESC'
)
// Access to the content has already been verified. Disable query-level
// access checking so that revisions for unpublished content still
// appear.
->
accessCheck
(
FALSE
)
->
execute
();
$vids
=
\array_keys
(
$query
);
$revision_count
=
\count
(
$vids
);
$revision_count
=
\count
(
$vids
);
$build
[
'#title'
]
=
$has_translations
?
$this
->
t
(
'@langname revisions for %title'
,
[
$build
[
'#title'
]
=
$has_translations
?
$this
->
t
(
'@langname revisions for %title'
,
[
...
@@ -250,6 +238,7 @@ class RevisionOverviewForm extends FormBase {
...
@@ -250,6 +238,7 @@ class RevisionOverviewForm extends FormBase {
'#type'
=>
'pager'
,
'#type'
=>
'pager'
,
];
];
$build
[
'#attached'
][
'library'
][]
=
'node/drupal.node.admin'
;
$build
[
'#attached'
][
'library'
][]
=
'node/drupal.node.admin'
;
$form_state
->
set
(
'workspace_safe'
,
TRUE
);
return
$build
;
return
$build
;
}
}
...
@@ -258,9 +247,9 @@ class RevisionOverviewForm extends FormBase {
...
@@ -258,9 +247,9 @@ class RevisionOverviewForm extends FormBase {
*
*
* @param string $name
* @param string $name
* Name attribute.
* Name attribute.
* @param
str
in
g
$return_val
* @param in
t
$return_val
* Return value attribute.
* Return value attribute.
* @param
string
$default_val
* @param
int|false
$default_val
* Default value attribute.
* Default value attribute.
*
*
* @return array
* @return array
...
@@ -276,6 +265,29 @@ class RevisionOverviewForm extends FormBase {
...
@@ -276,6 +265,29 @@ class RevisionOverviewForm extends FormBase {
];
];
}
}
/**
* Gets all the revision IDs for the given node.
*
* @param \Drupal\node\NodeInterface $node
* The node entity.
*
* @return int[]
* The revision IDs.
*/
protected
function
getRevisionIds
(
NodeInterface
$node
):
array
{
$result
=
$this
->
entityTypeManager
->
getStorage
(
'node'
)
->
getQuery
()
->
condition
(
$node
->
getEntityType
()
->
getKey
(
'id'
),
$node
->
id
())
->
pager
(
$this
->
config
->
get
(
'general_settings.revision_pager_limit'
))
->
allRevisions
()
->
sort
(
$node
->
getEntityType
()
->
getKey
(
'revision'
),
'DESC'
)
// Access to the content has already been verified. Disable query-level
// access checking so that revisions for unpublished content still
// appear.
->
accessCheck
(
FALSE
)
->
execute
();
return
\array_keys
(
$result
);
}
/**
/**
* Set and return configuration for revision.
* Set and return configuration for revision.
*
*
...
...
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