AccountProxy instead of AccountProxyInterface
Problem/Motivation
When ECA is installed and Stacked Permissions is also installed, you get an error when trying to open or create an ECA model. This is due to the fact that Stacked Permissions replaces Drupal’s current_user service with its own class Drupal\stacked_permissions\StackedPermissionsAccountProxy. That service implements AccountProxyInterface, but it is not the concrete Drupal\Core\Session\AccountProxy class. The bpmn_io module’s Converter constructor is hard-typed to the concrete class (public function __construct( ..., \Drupal\Core\Session\AccountProxy $currentUser, ... )). So when the container injects the (perfectly valid) StackedPermissionsAccountProxy, PHP throws:
"must be of type Drupal\Core\Session\AccountProxy, Drupal\stacked_permissions\StackedPermissionsAccountProxy given"
Note: The models will still run when they are supposed to and that part works. Its just the editing of the model or creating a new one that is broken.
Steps to reproduce
On fresh drupal site, install both eca and stacked permissions.
Proposed resolution
Maybe it would be to type-hint AccountProxyInterface (or even AccountInterface) for the @current_user service, not the concrete AccountProxy class.
Idea:
Change the constructor type-hint in web/modules/contrib/bpmn_io/src/Services/Converter/Converter.php from AccountProxy to AccountProxyInterface, and update the use statement.
class Converter {
- public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountProxy $currentUser, TranslationInterface $string_translation) {
+ public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountProxyInterface $currentUser, TranslationInterface $string_translation) {
$this->entityTypeManager = $entity_type_manager;
$this->moduleHandler = $module_handler;
$this->currentUser = $currentUser;