Skip to content

Commit

Permalink
Merge branch 'hotfix/v2.1.51'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Nov 20, 2023
2 parents 0ab294d + d7703fb commit 0fca740
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 160 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [v2.1.51](https://github.com/roadiz/core-bundle-dev-app/compare/v2.1.50...v2.1.51) (2023-11-20)


### Bug Fixes

* Fixed missing entityManager flush to remove custom-form answer. ([e9aa0ba](https://github.com/roadiz/core-bundle-dev-app/commit/e9aa0ba826244024426a0484a4e19a51008cbda2))

## [v2.1.50](https://github.com/roadiz/core-bundle-dev-app/compare/v2.1.49...v2.1.50) (2023-11-16)


Expand Down
2 changes: 1 addition & 1 deletion lib/RoadizCoreBundle/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
parameters:
roadiz_core.cms_version: '2.1.50'
roadiz_core.cms_version: '2.1.51'
roadiz_core.cms_version_prefix: 'main'
env(APP_NAMESPACE): "roadiz"
env(APP_VERSION): "0.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
use Themes\Rozier\RozierApp;
use Twig\Error\RuntimeError;

/**
* @package Themes\Rozier\Controllers
Expand All @@ -24,11 +25,12 @@ class CustomFormAnswersController extends RozierApp
* List every node-types.
*
* @param Request $request
* @param int $customFormId
* @param int $customFormId
*
* @return Response
* @throws RuntimeError
*/
public function listAction(Request $request, int $customFormId)
public function listAction(Request $request, int $customFormId): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_CUSTOMFORMS');
/*
Expand All @@ -55,58 +57,57 @@ public function listAction(Request $request, int $customFormId)
}

/**
* Return an deletion form for requested node-type.
* Return a deletion form for requested node-type.
*
* @param Request $request
* @param int $customFormAnswerId
*
* @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $customFormAnswerId)
public function deleteAction(Request $request, int $customFormAnswerId): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_CUSTOMFORMS_DELETE');

$customFormAnswer = $this->em()->find(CustomFormAnswer::class, $customFormAnswerId);

if (null !== $customFormAnswer) {
$this->assignation['customFormAnswer'] = $customFormAnswer;

$form = $this->buildDeleteForm($customFormAnswer);

$form->handleRequest($request);

if (
$form->isSubmitted() &&
$form->isValid() &&
$form->getData()['customFormAnswerId'] == $customFormAnswer->getId()
) {
$this->em()->remove($customFormAnswer);

$msg = $this->getTranslator()->trans('customFormAnswer.%id%.deleted', ['%id%' => $customFormAnswer->getId()]);
$this->publishConfirmMessage($request, $msg);
/*
* Redirect to update schema page
*/
return $this->redirectToRoute(
'customFormAnswersHomePage',
["customFormId" => $customFormAnswer->getCustomForm()->getId()]
);
}

$this->assignation['form'] = $form->createView();
if (null === $customFormAnswer) {
throw new ResourceNotFoundException();
}

return $this->render('@RoadizRozier/custom-form-answers/delete.html.twig', $this->assignation);
$this->assignation['customFormAnswer'] = $customFormAnswer;
$form = $this->buildDeleteForm($customFormAnswer);
$form->handleRequest($request);

if (
$form->isSubmitted() &&
$form->isValid()
) {
$this->em()->remove($customFormAnswer);
$this->em()->flush();

$msg = $this->getTranslator()->trans('customFormAnswer.%id%.deleted', ['%id%' => $customFormAnswer->getId()]);
$this->publishConfirmMessage($request, $msg);
/*
* Redirect to update schema page
*/
return $this->redirectToRoute(
'customFormAnswersHomePage',
["customFormId" => $customFormAnswer->getCustomForm()->getId()]
);
}

throw new ResourceNotFoundException();
$this->assignation['form'] = $form->createView();

return $this->render('@RoadizRozier/custom-form-answers/delete.html.twig', $this->assignation);
}

/**
* @param CustomFormAnswer $customFormAnswer
*
* @return FormInterface
*/
private function buildDeleteForm(CustomFormAnswer $customFormAnswer)
private function buildDeleteForm(CustomFormAnswer $customFormAnswer): FormInterface
{
$builder = $this->createFormBuilder()
->add('customFormAnswerId', HiddenType::class, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace Themes\Rozier\Controllers\CustomForms;

use Doctrine\Common\Collections\Collection;
use RZ\Roadiz\CoreBundle\Entity\CustomFormAnswer;
use RZ\Roadiz\CoreBundle\Entity\CustomFormFieldAttribute;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Themes\Rozier\RozierApp;
use Twig\Error\RuntimeError;

/**
* @package Themes\Rozier\Controllers
Expand All @@ -19,11 +20,12 @@ class CustomFormFieldAttributesController extends RozierApp
* List every node-types.
*
* @param Request $request
* @param int $customFormAnswerId
* @param int $customFormAnswerId
*
* @return \Symfony\Component\HttpFoundation\Response
* @return Response
* @throws RuntimeError
*/
public function listAction(Request $request, int $customFormAnswerId)
public function listAction(Request $request, int $customFormAnswerId): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_CUSTOMFORMS');
/*
Expand All @@ -42,10 +44,10 @@ public function listAction(Request $request, int $customFormAnswerId)
}

/**
* @param Collection|array $answers
* @param iterable $answers
* @return array
*/
protected function getAnswersByGroups($answers)
protected function getAnswersByGroups(iterable $answers): array
{
$fieldsArray = [];

Expand Down
Loading

0 comments on commit 0fca740

Please sign in to comment.