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

Improve ParamConverterManager and developer experience for ParamConverters

$
0
0

Follow-up on #1798214: Upcast request arguments/attributes to full objects

In #1798214: Upcast request arguments/attributes to full objects we introduced RouteEnhancers as part of the DynamicRouter from Symfony2 CMF.

RouteEnhancers essentially are request manipulators. More precisely: When a request is processed through DynamicRouter::matchRequest() all registered RouteEnhancers are invoked and get a chance to alter the request. Among other things, this gives us the chance to upcast variables from the URL.
Upcasting means that variables from a request, e.g. so called {slug}'s (for example /node/{node}), are converted to full objects (e.g. Node) which results in the actual controller (page callback) receiving the fully loaded objects instead of the plain variable string.

Specifically for that (upcasting) #1798214: Upcast request arguments/attributes to full objects implements a special RouteEnhancer called "ParamConverterManager" which allows specialized ParamConverters to be registered with it in order to further abstract route enhancing specifically for upcasting said {slug}'s into proper objects (and just that). Furthermore, the ParamConverterManager throws a 404 if upcasting for one or more of the given {slug}'s fails (e.g. if a non-existent node id was requested).

In my opinion the main difference to Drupal 7 is (despite the fact that the underlying system is completely different) that instead of specifically registering and invoking 'menu loaders' (e.g. node/%node => node_load()) the ParamConverterManager does not know which ParamConverter is responsible for upcasting which {slug}... It simply loops over all the registered converters and hopes that, when finished, everything has been loaded properly. This gives us more flexibility (and less complexity) but also less control over what exactly is happening.

The goal of this issue is to further improve the ParamConverterManager and the developer experience for ParamConverters.


Viewing all articles
Browse latest Browse all 293682

Trending Articles



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