No port yet, sorry ;)
Just a quick information for whoever wants to try and port this module to Drupal 8.
It is no longer possible to redirect within hook_node_view().
Instead, a event listener on request, that comes immediately after the routing happened (REQUEST event, prio > 32), then, do something like this:
if ($request->attributes->has('_route') && $request->attributes->get('_route') == 'entity.node.canonical') {
$node = $request->attributes->get('node');
if ($node instanceof NodeInterface && $node->getType() == $node_type) {
$event->setResponse(new RedirectResponse($url)
}
}
404 and 403 should also be possible with this.
This has the advantage to be much more reliable than the hook and faster, because the check happens right after the route was identified, and the node does not need to be built at all
Comments
Comment #1
olofbokedal commentedNice with some initial information! I'm planning on starting the 8.x version somewhere in january/february, if no one else starts before.
I'm guessing that the entire module will need a huge overhaul.
Comment #2
ttamniwdoog commentedHas anyone started this? I have interest and am working on a lite version of this for D8 now.
Comment #3
francewhoaWe would be happy to contribute testing patch, quality assurance, documentation, and agile project management services if needed
Any additional volunteers to join the efforts to port Rabbit Hole module from Drupal 7 to 8?
Related pages
Comment #4
mparker17I've started porting the module, but it's HIGHLY incomplete (at this point, it doesn't even pass it's own tests and there's no real functionality).
I plan to continue working on this, but progress will be slow (as I can only work on this during the weekends)
***
My basic design goals here are:
Comment #5
mparker17Still highly incomplete, but at least I can get tests to pass and the behavior plugins to work properly.
Comment #6
dylan donkersgoed commentedI'm adding a small continuation of mparker17's work. This patch starts converting the old variable system to Drupal 8's new configuration management API.
Comment #7
dylan donkersgoed commentedI've added a significant chunk of new work to improve the configuration and get the forms working for nodes for basic actions. The redirect options aren't fully configured yet. Most of the infrastructure for the entity plugin system doesn't exist yet. A couple lines are just hardcoded for nodes at the moment.
Next I plan to tie together the form and mparker17's behavior plugins to get something actually functional (i.e. visit a node and have a behavior plugin run based on which action is selected). This is the bit mentioned in the description of the issue. After that I plan on getting the redirect options working. At that point I'll likely post another update to this issue.
Comment #8
dylan donkersgoed commentedSorry about the long delay for this one.
What's New
Some simple behaviors are actually invoked now - access denied, display page, page not found, and redirects (kinda) can be configured for nodes (including content type defaults) and will actually be invoked.
The redirect code is necessarily very different from the Drupal 7 code. You can see it hooks into the request in src/EventSubscriber/RabbitHoleSubscriber, how the plugins are loaded and invoked in src/BehaviorInvoker.php and what actually happens in the src/Plugin/PageRedirect.php. There's some stuff in there that I'm not 100% sure of (especially regarding 304 and 305 redirects) and I'd be interested in opinions on it/alternate suggestions.
mparker17: I modified/expanded your plugin system in this patch. Notably the redirect plugin has been changed significantly and there are some new methods + new arguments in many of the method headers. I'd be interested in hearing your thoughts on that. There are some parts that I'm not certain I did in the way you originally intended with your plugin system.
What's Next
Next I plan to get the plugin system for adding rabbit hole to different entity types working. Likely my next patch will have the basic structure of it, a node implementation and probably one other entity implementation or partial implementation to make sure it works properly.
Other Stuff To Do
There are some other things that need to be done that probably won't be done in my next patch, including:
Comment #9
dylan donkersgoed commentedNew patch. The entity plugin system is now more functional with implementations for node and user. Nodes work pretty much the same as before but now they use the entity plugin system more. There's a related new feature in the entity plugin system which is used by the user implementation - a global configuration form for all entities of a type, accessible from the account settings form like in Drupal 7.
Next I'm planning to set up the permissions and security checks that used to exist. I'm hoping that won't take too long but I'm not sure when I'll get to it. That should bring the module to a usable state I think, though of course it won't have all the features the Drupal 7 version does yet.
Comment #10
mparker17Removed most code which has been commented-out.
Comment #11
mparker17Run
phpcbf --standard=Drupal .andphpcbf --standard=DrupalPractice .to fix the easiest coding-standards violations.Comment #12
mparker17phpcs --standard=DrupalPractice .identified a bunch of variables that were being assigned to but never used; and also an instance where we were checkingisset($x) ? $x : $ywhen$xhad never been assigned and thus could never exist.Comment #13
mparker17Started fixing issues identified by
phpcs --standard=Drupal .(still more to do, I just ran out of time).
Comment #14
mparker17Finished fixing issues identified by
phpcs --standard=Drupal .Comment #15
rooby commentedIs there a todo list for what is remaining to complete this patch or is it ready for review?
Comment #16
dylan donkersgoed commentedThere were some renaming issues with the standards compliance fixes, adding a patch to fix those.
Comment #17
dylan donkersgoed commentedAdding a patch with the per-entity rabbit hole permissions now. I think it may work a little differently than the Drupal 7 version - it's based on the entity types covered by the plugin. This should be functionally the same for the bundled modules but I'm not sure if it might have other implications.
Comment #18
dylan donkersgoed commentedAdding a patch to fix a bug in a test related to the previous patch.
Comment #19
dylan donkersgoed commentedAdding a patch to fix a bug that could cause uninstall to fail.
Comment #20
dylan donkersgoed commentedAdding a patch to make entities respect redirect configuration of bundles when configured to use bundle action with bundle action being redirect.
The module should currently technically be functional. Here's a summary of what I think the status is:
Comment #21
vasi1186 commentedI had some issue when trying to redirect to the frontpage. I attached a new patch which should solve this.
Comment #22
dylan donkersgoed commentedI'm attaching a patch to add a rh_taxonomy module, courtesy of one of my co-workers who declined to upload it/be tagged on it. This is a good example of a simple implementation of submodules for new entities. File entity support still needs to be implemented.
Comment #23
dylan donkersgoed commentedI'm attaching a patch with some Drupal standards and best practices fixes.
Comment #24
dylan donkersgoed commentedAnother quick patch to remove some done TODOs and move the token TODO to a more appropriate place in the code.
Comment #25
dylan donkersgoed commentedI'm adding a simple patch that brings in the README from the D7 repo. I haven't made any changes to the actual file as there's not really anything Drupal 8 specific in there. There's definitely room for improvement, but I think the module is ready for some wider usage/testing.
olofjohansson: If you think it's ready, could you please create an 8.x branch for this port?
Comment #26
itsekhmistro commentedPlease create 8.x branch from the Patch attached in comment #25.
The patch has been tested and works pretty well as for me. It will be much easier to continue development in git branch.
Comment #28
olofbokedal commentedHey guys!
Sorry for my absence and late response, but I'd just wanted to let you know that I've created a branch for 8.x where I applied the patch from #25. I've also added Dylan and mparker17 as co-maintainers (based on number of patches) with permissions to write to VCS, maintain issues and releases. Please let me know if there's someone else that should get access. I've just created an initial dev release of 8.x-1.x, should be visible on the project page soon enough.
Great work guys! The community really appreciates your effort :)
Feel free to close this issue whenever you're satisfied with the initial port.
Comment #29
mparker17Cool! Thanks! I think @Dylan Donkersgoed deserves most of the credit though; I just helped clean up a bit.
Comment #30
luksakWorks great so far. Should we close this an start creating separate issues?
Comment #31
temkin commentedI think it's fair to say that the module was successfully ported to D8. Me and a few other people are already using it in production mode. Therefore I'm closing this ticket and we can have separate issues for all other bugfixes and changes.
Thanks everyone!