As you said, node revision does not have hook implement for check access. So you need other way to resolved your problem. My way is alter existing services. Just following document, there is file my_module/src/MyModuleServiceProvider.php
<?php
namespace Drupal\my_module;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Symfony\Component\DependencyInjection\Reference;
/**
* Class MyModuleServiceProvider.
*
* @package Drupal\mymodule
*/
class MyModuleServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
$definition = $container->getDefinition('access_check.node.revision');
$definition->setClass('Drupal\my_module\Access\MyModuleNodeRevisionAccessCheck');
$definition->setArguments(
[
new Reference('entity.manager'),
]
);
}
}
After alter access_check.node.revision service. I'll define new class check access view node revision with extend class NodeRevisionAccessCheck and override method access like this. File src/Access/MyModuleNodeRevisionAccessCheck
<?php
namespace Drupal\my_module\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\node\Access\NodeRevisionAccessCheck;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
use Symfony\Component\Routing\Route;
/**
* Provides an access checker for node revisions.
*
* @ingroup node_access
*/
class MyModuleNodeRevisionAccessCheck extends NodeRevisionAccessCheck {
public function access(Route $route, AccountInterface $account, $node_revision = NULL, NodeInterface $node = NULL) {
if ($node_revision) {
$node = $this->nodeStorage->loadRevision($node_revision);
}
$operation = $route->getRequirement('_access_node_revision');
// You can override logic check access here or provide a new hook.
}
}