Updated: Comment 0

Problem/Motivation

Currently it is really exhausting to register a access checker as you have to create a service and specify the right tab.

Let's drop the need to specify a tag.

Before

  views.route_access_check:
    class: Drupal\views\ViewsAccessCheck
    tags:
      - { name: 'access_check' }

After

  views.route_access_check:
    class: Drupal\views\ViewsAccessCheck

Proposed resolution

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
Issue tags: +DX (Developer Experience)
FileSize
79.63 KB

Here is a simple try.

Status: Needs review » Needs work

The last submitted patch, access-2048223-70.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
11.02 KB

This was the wrong patch.

Status: Needs review » Needs work

The last submitted patch, access-2100131-2.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
11.06 KB

This was also wrong.

Status: Needs review » Needs work

The last submitted patch, access-2100131-3.patch, failed testing.

dawehner’s picture

For some odd reasons the class are boolean at some point etc,

WD php: Warning: class_implements(): Class Drupal\user\TempStoreFactory does not exist and could not be loaded in Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass->process() (line 29 of                                                             [warning]
/var/www/d8/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php).
WD php: Warning: class_implements(): Class Drupal\system\Plugin\ImageToolkitManager does not exist and could not be loaded in Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass->process() (line 29 of                                                 [warning]
/var/www/d8/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php).
WD php: Warning: class_implements(): Class Drupal\system\Plugin\ImageToolkitInterface does not exist and could not be loaded in Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass->process() (line 29 of                                               [warning]
/var/www/d8/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php).
WD php: Warning: class_implements(): Class Drupal\user\TempStoreFactory does not exist and could not be loaded in Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass->process() (line 29 of                                                             [warning]
/var/www/d8/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php).
WD php: Warning: class_implements(): Class Drupal\system\Plugin\ImageToolkitManager does not exist and could not be loaded in Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass->process() (line 29 of                                                 [warning]
/var/www/d8/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php).
WD php: Warning: class_implements(): Class Drupal\system\Plugin\ImageToolkitInterface does not exist and could not be loaded in Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass->process() (line 29 of                                               [warning]
/var/www/d8/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php).
WD php: ReflectionException: Class Drupal\user\TempStoreFactory does not exist in ReflectionClass->__construct() (line 961 of /var/www/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php).                        [error]
ReflectionException: Class Drupal\user\TempStoreFactory does not exist in ReflectionClass->__construct() (line 961 of /var/www/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php).
Drush command terminated abnormally due to an unrecoverable error.    
pwolanin’s picture

Status: Needs work » Needs review
FileSize
1.11 KB
11.3 KB

I think it might work using is_subclass_of()

Status: Needs review » Needs work

The last submitted patch, access-2100131-8.patch, failed testing.

dawehner’s picture

dawehner’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

... We don't do something similar somewhere else, so I don't think its worth to do. Maybe in 8.1.x we could introduce a general patterns
for all interface based services.

Note: Access checkers would need a specific tag anyway now, see the following example:

    tags:
  access_check.user.role:
    class: Drupal\user\Access\RoleAccessCheck
      - { name: access_check, applies_to: _role }