Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After apply the changes proposed in the Issue https://www.drupal.org/project/humanstxt/issues/3102514, the module must create a link tag in the section of the rendered pages, linking to the new humans.txt file.
Comments
Comment #2
davidjguruI provide this patch with a solution adapted to Drupal 8, using the property #attached from inside a hook page_attachments() in a .module file.
Comment #3
davidjguruComment #4
pcambraMany thanks! here are a few nitpicks with the patch.
This seems unused
This doesn't need to be break into multiple lines.
Nitpick, missing space after "if" and it's not needed to compare with TRUE, maybe you could directly do "if ($display_link_in_header = \Drupal::config('humanstxt.settings')->get('display_link')) {" instead
No need of all these variables, you could do the string concatenation in one or two lines.
Shouldn't this be ".humans.txt"?
Again, the $link description variable is not reused, you could just assign the array directly without extra variables.
Comment #5
pcambraAfter reviewing #3102492: Make some small adjustments in Routing, I think it would be useful to create a humans.txt route in the routing files, what do you think?
Comment #6
davidjguruHi,
I've revised the former patch and prepared a new version, just a lighter iteration based on all the notes and 'nitpicks' from the feedback.
This works fine and creates the link to the file using less code.
Greetings,
David.
Comment #7
davidjguruComment #8
pcambraThanks, a couple of comments below:
This is what I meant with the route, we probably want to create a route in the routing.yml so we don't need to do this.
Please review the coding standards regarding arrays as I don't think this follows them.
Comment #9
davidjguruI just uploaded a new version of the patch using the new route from the routing file and building the link to the humans.txt file using the format marked as in: web/core/modules/system/tests/modules/render_attached_test/src/Controller/RenderAttachedTestController.php
(https://api.drupal.org/api/drupal/core%21modules%21system%21tests%21modules%21render_attached_test%21src%21Controller%21RenderAttachedTestController.php/function/RenderAttachedTestController%3A%3AhtmlHeaderLink/8.8.x)
Comment #10
davidjguruComment #11
pcambraPostponing this until we get the controller in
Comment #12
pcambraI think this is unlocked now, not sure if the patch needs to be changed, feel free to change the status to NR.
Comment #13
davidjguruI'm reloading the patch, I've reduced a string in a comment.
You can test with this.
Comment #14
davidjguruComment #15
pcambraNow that I look this on detail, you can do fromRoute and then send absolute=>TRUE in the options array for getting the full URL.
Comment #16
davidjguruI just reload a new version of the patch with the mentioned changed in the fromRoute method.
Please, review.
Greetings,
David.
Comment #17
davidjguruComment #18
davidjguruComment #20
pcambraPushed with a few changes, thanks!