Skip to content

Instantly share code, notes, and snippets.

@ricfrank
Created December 19, 2012 17:46
Show Gist options
  • Save ricfrank/4338691 to your computer and use it in GitHub Desktop.
Save ricfrank/4338691 to your computer and use it in GitHub Desktop.
Controller
/**
* Creates a new Banner entity.
*
* @Route("/create", name="admin_banner_create")
* @Method("post")
* @Template("MySomethingBundle:AdminBanner:index.html.twig")
*/
public function createAction()
{
$entity = new Banner();
$request = $this->getRequest();
$form = $this->createForm(new BannerType(), $entity);
$form->bindRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
}
$banners = $this->getBannerList($em);
return $this->redirect($this->generateUrl('admin_banner_list', array('big_banners' => $banners->get('bigBanners'), 'small_banners' => $banners->get('smallBanners'))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment