Custom route access

The previous ways of controlling routes are powerful and relatively flexible, but static. We are hardcoding the rules into a file and expect the incoming user to abide by them. However, what if things are more complicated than that, and we need a more dynamic approach? Trust me, things get complicated, fast. We can use the _custom_access option of the route requirements.

In this subsection, we will see how these work and how we can create our custom access checkers. Just something simple to demonstrate the process. Then, we will see a more advanced implementation that will have us work a bit with routes programmatically.

There are two ways custom access checkers can be created and used with a route, and they both involve ...

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.