Skip to content

Commit

Permalink
IBX-8485: Applied review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Jul 9, 2024
1 parent 350fbcb commit 87d7374
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/bundle/Controller/LocationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,35 +488,38 @@ public function addAction(Request $request): Response

$contentInfo = $form->getData()->getContentInfo();

$referer = $request->headers->get('referer');
$referer = $request->headers->get('Referer');

if ($form->isSubmitted()) {
$result = $this->submitHandler->handle($form, function (ContentLocationAddData $data) use ($referer) {
$contentInfo = $data->getContentInfo();

foreach ($data->getNewLocations() as $newLocation) {
$locationCreateStruct = $this->locationService->newLocationCreateStruct($newLocation->id);
$this->locationService->createLocation($contentInfo, $locationCreateStruct);

$this->notificationHandler->success(
/** @Desc("Location '%name%' created.") */
'location.create.success',
['%name%' => $newLocation->getContentInfo()->name],
'ibexa_location'
$result = $this->submitHandler->handle(
$form,
function (ContentLocationAddData $data) use ($referer): RedirectResponse {
$contentInfo = $data->getContentInfo();

foreach ($data->getNewLocations() as $newLocation) {
$locationCreateStruct = $this->locationService->newLocationCreateStruct($newLocation->id);
$this->locationService->createLocation($contentInfo, $locationCreateStruct);

$this->notificationHandler->success(
/** @Desc("Location '%name%' created.") */
'location.create.success',
['%name%' => $newLocation->getContentInfo()->name],
'ibexa_location',
);
}

$redirectUrl = $referer ?: $this->generateUrl(
'ibexa.content.view',
[
'contentId' => $contentInfo->id,
'locationId' => $contentInfo->mainLocationId,
'_fragment' => LocationsTab::URI_FRAGMENT,
],
);
}

$redirectUrl = $referer ?: $this->generateUrl(
'ibexa.content.view',
[
'contentId' => $contentInfo->id,
'locationId' => $contentInfo->mainLocationId,
'_fragment' => LocationsTab::URI_FRAGMENT,
],
);

return new RedirectResponse($redirectUrl);
});
return new RedirectResponse($redirectUrl);
}
);

if ($result instanceof Response) {
return $result;
Expand Down

0 comments on commit 87d7374

Please sign in to comment.