public function createAction(Request $request) { $bannerZone = $this->bannerZoneManager->create(); $form = $this->formFactory->create($bannerZone); if ($this->formHandler->process($form, $request)) { $this->bannerZoneManager->save(); $this->eventDispatcher->dispatch(BannerZoneEvents::CREATE, $this->createEvent($bannerZone, $request)); return $this->formHandler->onSuccess(); } return $this->templating->renderResponse('SilvestraBannerBundle:BannerZone:create.html.twig', array('form' => $form->createView())); }
/** * Create banner zone. * * @param BannerZoneConfig $config * * @return BannerZoneInterface */ private function createZone(BannerZoneConfig $config) { list($width, $height) = $config->getSize(); $zone = $this->manager->create(); $name = $config->getName(); if ($config->getTranslationDomain()) { $name = $this->translator->trans($name, array(), $config->getTranslationDomain()); } $zone->setName($name); $zone->setCode($config->getSlug()); $zone->setSlug($config->getSlug()); $zone->setWidth($width); $zone->setHeight($height); $zone->setSystem(true); $this->manager->add($zone); return $zone; }