Skip to content
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

[WIP][POC] Add custom xkeys to response #25

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Resources/views/default
9 changes: 9 additions & 0 deletions app/config/views.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ezpublish:
system:
site:
content_view:
full:
default:
controller: AppBundle\Controller\TestController::xKeyAction
template: default/content/full.html.twig
match: true
1 change: 1 addition & 0 deletions docker/apache/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
imports:
- { resource: cache_pool/cache.redis.yml }
- { resource: views.yml }

parameters:
#TODO: May move all this to .env file or Dockerfile
Expand Down
23 changes: 23 additions & 0 deletions src/AppBundle/Controller/TestController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace AppBundle\Controller;

use eZ\Bundle\EzPublishCoreBundle\Controller;
use eZ\Publish\Core\MVC\Symfony\View\ContentView;
use Symfony\Component\HttpFoundation\Response;

class TestController extends Controller
{
public function xKeyAction(ContentView $view): ContentView
{
$response = new Response();

$locationIds = [123, 456];
//$response->headers->set('X-Location-Id', implode(',', $locationIds));
$response->headers->set('xkey', 'l'.implode(' l', $locationIds));
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In eZ Platform 3, it seems to be $response->headers->set('X-Cache-Tags',...


$view->setResponse($response);

return $view;
}
}