Skip to content
Snippets Groups Projects
Commit 028de1d1 authored by Kristiaan Van den Eynde's avatar Kristiaan Van den Eynde Committed by Kristiaan Van den Eynde
Browse files

Issue #3428392 by kristiaanvandeneynde: phpstan report: Call to deprecated...

Issue #3428392 by kristiaanvandeneynde: phpstan report: Call to deprecated method getName() of class Drupal\Core\Extension\ModuleHandlerInterface
parent d309cc5b
No related branches found
No related tags found
2 merge requests!193Issue #3304728 by kristiaanvandeneynde: Add member page missing due to...,!111Issue #3397021 by adamfranco: Add entity_mappings for phpstan-drupal
Pipeline #122200 passed
......@@ -91,7 +91,7 @@ services:
arguments: ['@entity_type.manager', '@current_user']
group.permissions:
class: 'Drupal\group\Access\GroupPermissionHandler'
arguments: ['@module_handler', '@string_translation', '@controller_resolver', '@group_relation_type.manager']
arguments: ['@module_handler', '@string_translation', '@controller_resolver', '@group_relation_type.manager', '@extension.list.module']
group_permission.hash_generator:
class: 'Drupal\group\Access\GroupPermissionsHashGenerator'
......
......@@ -4,6 +4,7 @@ namespace Drupal\group\Access;
use Drupal\Component\Discovery\YamlDiscovery;
use Drupal\Core\Controller\ControllerResolverInterface;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -79,6 +80,13 @@ class GroupPermissionHandler implements GroupPermissionHandlerInterface {
*/
protected $pluginManager;
/**
* The module extension list.
*
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $extensionListModule;
/**
* Constructs a new PermissionHandler.
*
......@@ -90,12 +98,19 @@ class GroupPermissionHandler implements GroupPermissionHandlerInterface {
* The controller resolver.
* @param \Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface $plugin_manager
* The group relation type manager.
* @param \Drupal\Core\Extension\ModuleExtensionList|null $extension_list_module
* The module extension list.
*/
public function __construct(ModuleHandlerInterface $module_handler, TranslationInterface $string_translation, ControllerResolverInterface $controller_resolver, GroupRelationTypeManagerInterface $plugin_manager) {
public function __construct(ModuleHandlerInterface $module_handler, TranslationInterface $string_translation, ControllerResolverInterface $controller_resolver, GroupRelationTypeManagerInterface $plugin_manager, ModuleExtensionList $extension_list_module = NULL) {
if ($extension_list_module === NULL) {
@trigger_error('Calling ' . __METHOD__ . ' without the $extension_list_module argument is deprecated in group:3.3.0 and will be required in group:4.0.0. See https://www.drupal.org/node/3431243', E_USER_DEPRECATED);
$extension_list_module = \Drupal::service('extension.list.module');
}
$this->moduleHandler = $module_handler;
$this->stringTranslation = $string_translation;
$this->controllerResolver = $controller_resolver;
$this->pluginManager = $plugin_manager;
$this->extensionListModule = $extension_list_module;
}
/**
......@@ -292,7 +307,7 @@ class GroupPermissionHandler implements GroupPermissionHandlerInterface {
protected function getModuleNames() {
$modules = [];
foreach (array_keys($this->moduleHandler->getModuleList()) as $module) {
$modules[$module] = $this->moduleHandler->getName($module);
$modules[$module] = $this->extensionListModule->getName($module);
}
asort($modules);
return $modules;
......
......@@ -4,6 +4,7 @@ namespace Drupal\group\Entity\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group\Plugin\Group\Relation\GroupRelationTypeInterface;
......@@ -30,9 +31,9 @@ class GroupTypeController extends ControllerBase {
protected $pluginManager;
/**
* The module manager.
* The module extension list.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $moduleHandler;
......@@ -46,14 +47,18 @@ class GroupTypeController extends ControllerBase {
/**
* Constructs a new GroupTypeController.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Extension\ModuleExtensionList|\Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module extension list.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface $plugin_manager
* The group relation type manager.
*/
public function __construct(ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, GroupRelationTypeManagerInterface $plugin_manager) {
public function __construct(ModuleHandlerInterface|ModuleExtensionList $module_handler, EntityTypeManagerInterface $entity_type_manager, GroupRelationTypeManagerInterface $plugin_manager) {
if ($module_handler instanceof ModuleHandlerInterface) {
@trigger_error('Calling ' . __METHOD__ . '() with a $module_handler argument as \Drupal\Core\Extension\ModuleHandlerInterface instead of \Drupal\Core\Extension\ModuleExtensionList is deprecated in group:3.3.0 and will be required in group:4.0.0. See https://www.drupal.org/node/3431243', E_USER_DEPRECATED);
$module_handler = \Drupal::service('extension.list.module');
}
$this->moduleHandler = $module_handler;
$this->entityTypeManager = $entity_type_manager;
$this->pluginManager = $plugin_manager;
......@@ -64,7 +69,7 @@ class GroupTypeController extends ControllerBase {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('module_handler'),
$container->get('extension.list.module'),
$container->get('entity_type.manager'),
$container->get('group_relation_type.manager')
);
......
......@@ -2,6 +2,7 @@
namespace Drupal\group\Form;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
......@@ -23,9 +24,9 @@ abstract class GroupPermissionsForm extends FormBase {
protected $groupPermissionHandler;
/**
* The module handler.
* The module extension list.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $moduleHandler;
......@@ -34,10 +35,14 @@ abstract class GroupPermissionsForm extends FormBase {
*
* @param \Drupal\group\Access\GroupPermissionHandlerInterface $permission_handler
* The group permission handler.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Extension\ModuleExtensionList|\Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module extension list.
*/
public function __construct(GroupPermissionHandlerInterface $permission_handler, ModuleHandlerInterface $module_handler) {
public function __construct(GroupPermissionHandlerInterface $permission_handler, ModuleHandlerInterface|ModuleExtensionList $module_handler) {
if ($module_handler instanceof ModuleHandlerInterface) {
@trigger_error('Calling ' . __METHOD__ . '() with a $module_handler argument as \Drupal\Core\Extension\ModuleHandlerInterface instead of \Drupal\Core\Extension\ModuleExtensionList is deprecated in group:3.3.0 and will be required in group:4.0.0. See https://www.drupal.org/node/3431243', E_USER_DEPRECATED);
$module_handler = \Drupal::service('extension.list.module');
}
$this->groupPermissionHandler = $permission_handler;
$this->moduleHandler = $module_handler;
}
......@@ -48,7 +53,7 @@ abstract class GroupPermissionsForm extends FormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('group.permissions'),
$container->get('module_handler')
$container->get('extension.list.module')
);
}
......
......@@ -4,6 +4,7 @@ namespace Drupal\group\Plugin\views\access;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\Context\ContextProviderInterface;
......@@ -39,9 +40,9 @@ class GroupPermission extends AccessPluginBase implements CacheableDependencyInt
protected $permissionHandler;
/**
* The module handler.
* The module extension list.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $moduleHandler;
......@@ -70,13 +71,17 @@ class GroupPermission extends AccessPluginBase implements CacheableDependencyInt
* The plugin implementation definition.
* @param \Drupal\group\Access\GroupPermissionHandlerInterface $permission_handler
* The group permission handler.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Extension\ModuleExtensionList|\Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module extension list.
* @param \Drupal\Core\Plugin\Context\ContextProviderInterface $context_provider
* The group route context.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, GroupPermissionHandlerInterface $permission_handler, ModuleHandlerInterface $module_handler, ContextProviderInterface $context_provider) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, GroupPermissionHandlerInterface $permission_handler, ModuleHandlerInterface|ModuleExtensionList $module_handler, ContextProviderInterface $context_provider) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
if ($module_handler instanceof ModuleHandlerInterface) {
@trigger_error('Calling ' . __METHOD__ . '() with a $module_handler argument as \Drupal\Core\Extension\ModuleHandlerInterface instead of \Drupal\Core\Extension\ModuleExtensionList is deprecated in group:3.3.0 and will be required in group:4.0.0. See https://www.drupal.org/node/3431243', E_USER_DEPRECATED);
$module_handler = \Drupal::service('extension.list.module');
}
$this->permissionHandler = $permission_handler;
$this->moduleHandler = $module_handler;
......@@ -94,7 +99,7 @@ class GroupPermission extends AccessPluginBase implements CacheableDependencyInt
$plugin_id,
$plugin_definition,
$container->get('group.permissions'),
$container->get('module_handler'),
$container->get('extension.list.module'),
$container->get('group.group_route_context')
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment