3 namespace Drupal\migrate_drupal_ui;
5 use Drupal\Core\Access\AccessResultAllowed;
6 use Drupal\Core\Session\AccountInterface;
9 * Checks access for migrate_drupal_ui routes.
11 * The Migrate Drupal UI can only be used by user 1. This is because any other
12 * user might have different permissions on the source and target site.
14 * This class is designed to be used with '_custom_access' route requirement.
16 * @see \Drupal\Core\Access\CustomAccessCheck
18 class MigrateAccessCheck {
21 * Checks if the user is user 1 and grants access if so.
23 * @param \Drupal\Core\Session\AccountInterface $account
24 * The current user account.
26 * @return \Drupal\Core\Access\AccessResult
29 public function checkAccess(AccountInterface $account) {
30 // The access result is uncacheable because it is just limiting access to
31 // the migrate UI which is not worth caching.
32 return AccessResultAllowed::allowedIf((int) $account->id() === 1)->mergeCacheMaxAge(0);