Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291271

Improve DX with EntityAccessControllerInterface

$
0
0

Currently, entity access controllers get separate methods for each $operation (view, delete, update, create). We originally did that in order to give developers a way to easily split up the code as some entities currently have a horrible amount of if/else and switches in their access callbacks due to the entire thing being forced into a single function callback. Now that we got entity access controllers we got that separation naturally but for some reason decided to force developers to use these namespaced methods via the interface (viewAccess, deleteAccess, etc.). Not only is that somewhat weird from an interface perspective and also considering the way it is currently invoked (we mostly map plain ->access() methods to ->{$operation}Access()).

Now, after converting a few of the core entity access callbacks to those new controllers it becomes clear that this step was not very well thought through and that the interface should probably just come with a plain ->access() method itself. We got the code separation already anyways due to us using controllers for that now. If a controller is complex enough it can very well still use separate methods, but we should not enforce it.

This issue should:

  • Simplify EntityAccessControllerInterface to only require a plain ->access() method with the $operation as an argument.
  • Convert all existing implementations to that new pattern and simplify wherever possible.

Viewing all articles
Browse latest Browse all 291271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>