3

Receiving the error "entity type did not specify a access handler", even though the entity type definitely does specify an access handler, like so:

/**
 * @ConfigEntityType(
 *   handlers = {
 *     "access" = "Drupal\give\GiveFormAccessControlHandler",
 *   },
 * )
 */

And the file src/GiveFormAccessControlHandler.php is in place and ready to handle access.

Why won't Drupal 8 see it?

2
  • The annotations are cached. Have you tried to rebuild the cache tables?
    – Eyal
    Jun 13, 2016 at 5:47
  • @Eyal: Thanks— stepping through with a debugger showed that the handler provided in the annotation was seen just fine (this may have been after a cache rebuild, for sure!) and the problem was that the file itself was not seen- and that required the class loader be refreshed (answer below), which rebuild doesn't currently do.
    – mlncn
    Jun 13, 2016 at 12:04

1 Answer 1

3

Drupal 8 made the decision to be fast by default and use the APC Classloader if it is available. It is faster, but it doesn't necessarily catch changes as you make them. To not have to restart your web server during development, you can set your local environment to not try to use a better-for-production class loader.

For instance, in local.settings.php add:

$settings['class_loader_auto_detect'] = FALSE;

As documented in settings.php:

If the APC extension is not detected, either because APC is missing or because auto-detection has been disabled, auto-loading falls back to Composer's ClassLoader, which is good for development as it does not break when code is moved in the file system.

In the issue where this change was made, Berdir warned that it would stymie developers. More background information at what to do when developing a Drupal 8 module and a class file just isn't being loaded even though it is definitely there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.