
| Current Path : /var/www/html/rocksensor/web/core/lib/Drupal/Core/Installer/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/rocksensor/web/core/lib/Drupal/Core/Installer/InstallerAccessPolicy.php |
<?php
namespace Drupal\Core\Installer;
use Drupal\Core\Session\AccessPolicyBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\CalculatedPermissionsItem;
use Drupal\Core\Session\RefinableCalculatedPermissionsInterface;
/**
* Grants user 1 an all access pass during install.
*
* @internal
* The policy is only to be used by the installer.
*/
final class InstallerAccessPolicy extends AccessPolicyBase {
/**
* {@inheritdoc}
*/
public function calculatePermissions(AccountInterface $account, string $scope): RefinableCalculatedPermissionsInterface {
$calculated_permissions = parent::calculatePermissions($account, $scope);
// Prevent the access policy from working when not in the installer.
if (((int) $account->id()) !== 1 || !InstallerKernel::installationAttempted()) {
return $calculated_permissions;
}
return $calculated_permissions->addItem(new CalculatedPermissionsItem([], TRUE));
}
/**
* {@inheritdoc}
*/
public function getPersistentCacheContexts(): array {
// Note that cache contexts in the installer are ignored because
// \Drupal\Core\Installer\NormalInstallerServiceProvider::register() changes
// everything to use a memory cache. If this was not the case, then this
// should also return a cache context related to the return value of
// \Drupal\Core\Installer\InstallerKernel::installationAttempted().
return ['user.is_super_user'];
}
}