Created
February 15, 2022 00:49
-
-
Save fredysan/8370a180c8b527918ef2b544dc2eae86 to your computer and use it in GitHub Desktop.
Debug Access Permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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