-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
TemplateView #6443
TemplateView #6443
Conversation
Let me give some examples of how this can be used. Say you want to modify a record: $app->view(function (TemplateView $view, Request $request) {
if ($view->context->has('record')) {
$record = $view->context->get('record');
// modify record
$view->context->set('record', $record);
}
}, 10 /* above default */); Say you want to add a header for a certain record: $app->after(function (Request $request, Response $response) {
if ($response instanceof TemplateResponse) {
$context = $response->getContext();
$record = isset($context['record']) ? $context['record'] : null;
if (/* if record is foo */) {
$response->headers->set('Foo', 'Bar');
}
}
}); Either of these could be used to retrieve the |
👍 This looks great! |
FWIW the conceptual approach, as it stands, has my 👍 |
Welcome to Monday, @CarsonF … Your friendly, weekly, "already-asking-too-much-of-a-person" nudge on this 🤗 |
587958b
to
bf85ac0
Compare
No movement on this for 5 weeks. Please don't forget, @CarsonF. :-) |
There is, it's just local. Haven't forgotten. |
bf85ac0
to
7a3324a
Compare
…y/template_view" config option is true. Added deprecation notice if still using TemplateResponse.
… they just can't be accessed from the response.
…. If false globals won't be assigned as twig globals. If globals are not needed this can be set to false. More code will come later to remove dependency on current twig globals (record and pager).
7a3324a
to
484aeff
Compare
This is ready for review now. |
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.
Looks good to me!
As discussed during the dev-meeting: |
In regards to #6382
Working on how this can be done without breaking BC, but it's proving challenging.
The only response method called in Frontend was the
X-XSS-Protection
header in record route. So I moved it out.Now you can do something like:
and then replace the
controller.frontend
service with that class.Open to ideas about how to integrate this further. I don't think changing
Controller\Base::render
directly is wise though, since others can base their controllers on it. But maybe if it's something just for Frontend / Backend classes that would be ok. I'm not sure if a separate shortcut even makes much since given how terse the line actually is.