Skip to content
Snippets Groups Projects

Resolve #3293558 "Workspaces support"

Merged Lucas Hedding requested to merge issue/diff-3293558:3293558-workspaces_support into 2.x
Files
2
@@ -19,6 +19,7 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\diff\DiffEntityComparison;
use Drupal\diff\DiffLayoutManager;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -78,20 +79,7 @@ class RevisionOverviewForm extends FormBase {
$node_storage = $this->entityTypeManager->getStorage('node');
$type = $node->getType();
$pagerLimit = $this->config->get('general_settings.revision_pager_limit');
$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);
$vids = $this->getRevisionIds($node);
$revision_count = \count($vids);
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', [
@@ -250,6 +238,7 @@ class RevisionOverviewForm extends FormBase {
'#type' => 'pager',
];
$build['#attached']['library'][] = 'node/drupal.node.admin';
$form_state->set('workspace_safe', TRUE);
return $build;
}
@@ -258,9 +247,9 @@ class RevisionOverviewForm extends FormBase {
*
* @param string $name
* Name attribute.
* @param string $return_val
* @param int $return_val
* Return value attribute.
* @param string $default_val
* @param int|false $default_val
* Default value attribute.
*
* @return array
@@ -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.
*
Loading