/** * Process banner delete. * * @param BannerZoneInterface $bannerZone * @param Request $request * * @return bool */ public function process($bannerZone, Request $request) { if ($request->isMethod('DELETE')) { if (false === $bannerZone->isSystem()) { $this->manager->remove($bannerZone); return true; } } return false; }
/** * Process banner zone form. * * @param FormInterface $form * @param Request $request * * @return bool */ public function process(FormInterface $form, Request $request) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { $this->bannerZoneManager->add($form->getData()); return true; } } return false; }
/** * Get banner zone or 404. * * @param int $bannerZoneId * * @return BannerZoneInterface * * @throws NotFoundHttpException */ private function getBannerZoneOr404($bannerZoneId) { $bannerZone = $this->bannerZoneManager->findById($bannerZoneId); if (null === $bannerZone) { throw new NotFoundHttpException(sprintf('Not found %s banner zone', $bannerZoneId)); } return $bannerZone; }
/** * 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; }