Implement copying of events.

Fixes #17
This commit is contained in:
Tim Schumacher 2014-09-17 17:50:24 +02:00
parent e8c94262d0
commit 9562a8d3a3
4 changed files with 41 additions and 7 deletions

View file

@ -305,4 +305,33 @@ class EventController extends Controller
);
}
/**
* Copies a Event entity.
*
* @Route("/termine/{slug}/kopieren", name="_copy")
* @Method("GET")
* @Template("CalciferBundle:Event:new.html.twig")
*/
public function copyAction(Request $request, $slug) {
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
/** @var EntityRepository $repo */
$repo = $em->getRepository('CalciferBundle:Event');
/** @var Event $entity */
$entity = $repo->findOneBy(['slug' => $slug]);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Event entity.');
}
$entity->id = null;
return array(
'entity' => $entity,
);
}
}