isActive(); $form = $this->createForm(ResourceFormType::class, $resource, [ 'action' => $this->generateUrl('app_admin_resource_edit', ['id' => $resource->getId()]), 'with_active' => true, ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->em->flush(); $this->audit->resourceUpdated($resource, $wasActive); $remaining = $wasActive && !$resource->isActive() ? $this->bookings->countFromDate($resource, new \DateTimeImmutable('today')) : 0; if ($remaining > 0) { $this->addFlash('warning', \sprintf( '%s ist nicht mehr buchbar. %d bestehende Buchungen ab heute bleiben erhalten.', $resource->getLabel(), $remaining, )); } else { $this->addFlash('success', \sprintf('%s gespeichert.', $resource->getLabel())); } return new HxRedirectResponse($this->generateUrl('app_admin_resource')); } return $this->render('admin/_modal_resource.html.twig', [ 'form' => $form, 'resource' => $resource, ]); } }