sa: Fix all issues related to PHP versions and static-analysis.

This commit is contained in:
Pol Dellaiera
2021-12-21 11:58:58 +01:00
parent b3823161af
commit b743475761
25 changed files with 79 additions and 81 deletions

View File

@@ -19,6 +19,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use function array_key_exists;
@@ -37,6 +38,7 @@ class AccompanyingCourseCommentController extends AbstractController
$newComment->setAccompanyingPeriod($accompanyingCourse);
$form = $this->createCommentForm($newComment, 'new');
$editForm = null;
if ($request->query->has('edit')) {
foreach ($accompanyingCourse->getComments() as $comment) {
@@ -53,12 +55,16 @@ class AccompanyingCourseCommentController extends AbstractController
}
}
if (null === $editForm) {
throw new NotFoundHttpException('Unable to find an edit form.');
}
if ($request->getMethod() === Request::METHOD_POST) {
$currentForm = $editForm->handleRequest($request);
if (array_key_exists('edit', $request->request->all()[$editForm->getName()])) {
$currentForm = $editForm->handleRequest($request);
$isEditingNew = false;
} else {
$currentForm = $form->handleRequest($request);
$isEditingNew = true;
}
@@ -79,7 +85,7 @@ class AccompanyingCourseCommentController extends AbstractController
return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [
'accompanyingCourse' => $accompanyingCourse,
'form' => $form->createView(),
'edit_form' => isset($editForm) ? $editForm->createView() : null,
'edit_form' => $editForm !== null ? $editForm->createView() : null,
'commentEditId' => $commentEditId ?? null,
]);
}