-
-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the Request available to the Formatter\Rendering event #1721
Conversation
This is important because extensions may wish to render post content differently depending on Request factors such as the actor. For example, an attachments extension might wish to hide attachments from guests. This solution is a bit of a hack-job for now, but soon when we refactor the API layer to use tobscure/json-api-server, and also refactor the Formatter layer, it can be revised.
Can you explain the use case in more detail? It does feel very icky to introduce dependencies to HTTP-level classes in our core domain code. |
Use-cases:
Basically, I'm arguing that rendering a post's content is intrinsically a request/actor-dependent process, just like serialising the rest of the post data is. The parsed post content is part of the core domain, but actually rendering it is a presentation-level event. |
Okay, but both of these examples only need the actor, not the request, right? |
Well yes, but I think the concept of an actor is still HTTP-level rather than domain. Take example use-case 1 but instead of being logged in you need to enter a password which sets a session flag to true. (I did something like this for another client who wanted certain tags to be password-protected.) API serializers should definitely be receiving the whole request (the equivalent in tobscure/json-api-server does) and by extension rendering should as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, then, looking forward to json-api-servers and more extenders. 😀
) This is important because extensions may wish to render post content differently depending on Request factors such as the actor. For example, an attachments extension might wish to hide attachments from guests. This solution is a bit of a hack-job for now, but soon when we refactor the API layer to use tobscure/json-api-server, and also refactor the Formatter layer, it can be revised.
Make the Request available to the Formatter\Rendering event.
This is important because extensions may wish to render post content
differently depending on Request factors such as the actor. For example,
an attachments extension might wish to hide attachments from guests.
This solution is a bit of a hack-job for now, but soon when we refactor
the API layer to use tobscure/json-api-server, and also refactor the
Formatter layer, it can be revised.
Confirmed
Frontend changes: tested on a local Flarum installation.php vendor/bin/phpunit
).