Skip to content

Commit

Permalink
Support custom keys for groups
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemN committed Jul 23, 2017
1 parent 32d7374 commit 56c6df1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion EventListener/ViewResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public function onKernelView(GetResponseForControllerResultEvent $event)

$context = $view->getContext();
if ($configuration->getSerializerGroups()) {
$context->addGroups($configuration->getSerializerGroups());
if (null === $context->getGroups()) {
$context->setGroups($configuration->getSerializerGroups());
} else {
$context->setGroups(array_merge($context->getGroups(), $configuration->getSerializerGroups()));
}
}
if ($configuration->getSerializerEnableMaxDepthChecks()) {
$context->setMaxDepth(0, false);
Expand Down
2 changes: 1 addition & 1 deletion View/ViewHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ protected function getSerializationContext(View $view)

$groups = $context->getGroups();
if (empty($groups) && $this->exclusionStrategyGroups) {
$context->addGroups($this->exclusionStrategyGroups);
$context->setGroups($this->exclusionStrategyGroups);
}

if (null === $context->getVersion() && $this->exclusionStrategyVersion) {
Expand Down

0 comments on commit 56c6df1

Please sign in to comment.