At last - to review. :)
Added tests.
Fixed weight.
@arunkumark
Please read the documentation of using RoutingEvents::ALTER and RoutingEvents::DYNAMIC from Drupal\Core\Routing\RouteBuilder.php
This code works AFTER route_callback
.
Removing the execution results of the old route_callback
is not a good idea, in my opinion.
It's much easier and better to use the new call instead of the old one - it's faster, easier and more reliable.
You didn't answer to my question, sorry.
I'll rephrase the question.
How to prevent execution of existing route_callback
call?
How to execute another function only? I don't need existing totally - I need a new one.
Strange.
The patch is applied successfully at my place locally on several Drupal variants.
Gathering patches for dependencies. This might take a minute.
- Installing drupal/core (11.0.0-rc1): Extracting archive
- Applying patches for drupal/core
https://git.drupalcode.org/project/drupal/-/merge_requests/8863.diff (Add alter for `route_callbacks`)
@arunkumark
If you can give me a better implementation - I will be very grateful.
I made this solution because I found no other options.
jsonapi.routing.yml
route_callbacks:
- '\Drupal\jsonapi\Routing\Routes::routes'
Explain me, please, how to alter route_callback
for jsonapi without call '\Drupal\jsonapi\Routing\Routes::routes'
According with \Drupal\Core\Routing\RouteBuilder::rebuild
Not from documentation (I know it) - check real code please.
$callback = $this->controllerResolver->getControllerFromDefinition($route_callback);
if ($callback_routes = call_user_func($callback)) {
vasyapledov β changed the visibility of the branch 3460831-alter-route-callback to active.
vasyapledov β changed the visibility of the branch 3460831-alter-route-callback to hidden.
vasyapledov β changed the visibility of the branch 11.x to active.
vasyapledov β changed the visibility of the branch 11.x to hidden.
vasyapledov β changed the visibility of the branch 3460831-alter-route-callback to active.
vasyapledov β changed the visibility of the branch 3460831-alter-route-callback to hidden.
This is the very draft variant of MultiAPI.
MulitAPI Functionality
- Unilimited numbers of JSON:API variants
- Independent JSON:API variants
- JSON:API variants can be enabled/disabled independently of each other
- JSON:API variants have independent path prefixes
Description
README MultiAPI.md
Installation
ATTENTION!
Before installation need to install core patchhttps://www.drupal.org/project/drupal/issues/3460831
vasyapledov β changed the visibility of the branch 3218679-ability-to-expose to active.
vasyapledov β changed the visibility of the branch 3218679-ability-to-expose to hidden.
vasyapledov β made their first commit to this issueβs fork.
Tested on 10.2.6
vasyapledov β created an issue.
For version 1.4.5 - need to check.
I made the same code for taxonomy term
and media
.
It works on my side - but need additional checks.
Yes, you are right. Fixed.
New variant.
Fixed. Need to check.
vasyapledov β created an issue.
First variant.
vasyapledov β created an issue.
Fix.
vasyapledov β created an issue.
Check this variant please.
Fixed in new release.
Fixed in a new release.
vasyapledov β created an issue.