Skip to content

Instantly share code, notes, and snippets.

@fredysan
Created February 15, 2022 00:49
Show Gist options
  • Save fredysan/8370a180c8b527918ef2b544dc2eae86 to your computer and use it in GitHub Desktop.
Save fredysan/8370a180c8b527918ef2b544dc2eae86 to your computer and use it in GitHub Desktop.
Debug Access Permissions
<?php
namespace Drupal\my_module\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Debug access.
*/
class DebugAccessController extends ControllerBase {
/**
* Builds the response.
*/
public function build() {
$account = \Drupal::entityTypeManager()->getStorage('user')->load(5195);
$route_name = \Drupal::service('router')->match('/admin/structure')['_route'];
$parameters = [];
// Checking the access.
$debug = \Drupal::service('access_manager')->checkNamedRoute($route_name, $parameters, $account, TRUE);
dump($debug);
return ['#markup' => $this->t('The page markup.')];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment