comparison core/modules/migrate_drupal_ui/src/MigrateAccessCheck.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\migrate_drupal_ui;
4
5 use Drupal\Core\Access\AccessResultAllowed;
6 use Drupal\Core\Session\AccountInterface;
7
8 /**
9 * Checks access for migrate_drupal_ui routes.
10 *
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.
13 *
14 * This class is designed to be used with '_custom_access' route requirement.
15 *
16 * @see \Drupal\Core\Access\CustomAccessCheck
17 */
18 class MigrateAccessCheck {
19
20 /**
21 * Checks if the user is user 1 and grants access if so.
22 *
23 * @param \Drupal\Core\Session\AccountInterface $account
24 * The current user account.
25 *
26 * @return \Drupal\Core\Access\AccessResult
27 * The access result.
28 */
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);
33 }
34
35 }