function PermissionHandler::__construct

Same name in other branches
  1. 9 core/modules/user/src/PermissionHandler.php \Drupal\user\PermissionHandler::__construct()
  2. 8.9.x core/modules/user/src/PermissionHandler.php \Drupal\user\PermissionHandler::__construct()
  3. 11.x core/modules/user/src/PermissionHandler.php \Drupal\user\PermissionHandler::__construct()

Constructs a new PermissionHandler.

Parameters

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler.

\Drupal\Core\StringTranslation\TranslationInterface $string_translation: The string translation.

\Drupal\Core\Utility\CallableResolver|\Drupal\Core\Controller\ControllerResolverInterface $callable_resolver: The callable resolver.

\Drupal\Core\Extension\ModuleExtensionList|null $moduleExtensionList: The module extension list.

File

core/modules/user/src/PermissionHandler.php, line 91

Class

PermissionHandler
Provides the available permissions based on yml files.

Namespace

Drupal\user

Code

public function __construct(ModuleHandlerInterface $module_handler, TranslationInterface $string_translation, ControllerResolverInterface|CallableResolver $callable_resolver, ?ModuleExtensionList $moduleExtensionList = NULL) {
    if ($callable_resolver instanceof ControllerResolverInterface) {
        @trigger_error('Calling ' . __METHOD__ . '() with an argument of ControllerResolverInterface is deprecated in drupal:10.2.0 and is removed in drupal:11.0.0. Use \\Drupal\\Core\\Utility\\CallableResolver instead. See https://www.drupal.org/node/3397954', E_USER_DEPRECATED);
        $callable_resolver = \Drupal::service('callable_resolver');
    }
    $this->callableResolver = $callable_resolver;
    // @todo It would be nice if you could pull all module directories from the
    //   container.
    $this->moduleHandler = $module_handler;
    $this->stringTranslation = $string_translation;
    if ($this->moduleExtensionList === NULL) {
        @trigger_error('Calling ' . __METHOD__ . '() without the $moduleExtensionList argument is deprecated in drupal:10.3.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3310017', E_USER_DEPRECATED);
        $this->moduleExtensionList = \Drupal::service('extension.list.module');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.