Skip to content

Instantly share code, notes, and snippets.

@araeuchle
Created November 2, 2015 21:27
Show Gist options
  • Save araeuchle/984b1307ffcbbf8effd8 to your computer and use it in GitHub Desktop.
Save araeuchle/984b1307ffcbbf8effd8 to your computer and use it in GitHub Desktop.
public function saveServiceDescriptionSortingAction(Request $request)
{
if ($request->isMethod('POST')) {
$items = $request->request->all()['item'];
$manager = $this->getDoctrine()->getManager();
$serviceDescriptionRepository = $manager->getRepository('SelfServiceBundle:PharmacyServiceDescription');
for ($i = 0; $i < count($items); $i++) {
/** @var \Dav\SelfServiceBundle\Entity\Normal\PharmacyServiceDescription $description */
$description = $serviceDescriptionRepository->findOneBy([
'id' => $items[$i]
]);
if ($description !== null) {
$description->setSorting($i);
$manager->persist($description);
}
}
$manager->flush();
}
$this->addFlash(
'notice',
'Ihre Sortierung wurde erfolgreich gespeichert.'
);
return new JsonResponse();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment