Example #1
0
 /** * @codeCoverageIgnore */
 public function createAction()
 {
     $repository = $this->getDoctrine()->getRepository('ElmetSiteBundle:CurtainPriceBand');
     $curtainPriceBand = $repository->findOneByName('A');
     $curtainDesign = new CurtainDesign();
     $curtainDesign->setUrlName("elevetham");
     $curtainDesign->setName("elevetham");
     $curtainDesign->setMaterials("100% Silk");
     $curtainDesign->setTapeSize("3");
     $curtainDesign->setLined('1');
     $curtainDesign->setEyeletsAvailable(1);
     $curtainDesign->setFabricWidth(140);
     $curtainDesign->setPatternRepeatLength(8.0);
     $curtainDesign->setFinish("Fringed");
     $curtainDesign->setCushionFinish("Corded");
     $curtainDesign->setNew('1');
     $curtainDesign->setCurtainPriceBand($curtainPriceBand);
     $curtainColour = new CurtainColour();
     $curtainColour->setName("Black");
     $curtainColour->setCurtainDesign($curtainDesign);
     $curtainColour->setFullFilepath("/fullpath");
     $curtainColour->setSwatchFilepath("/swatchpath");
     $curtainColour->setThumbnailFilepath("/thumbnailpath");
     $curtainColour->setInStock(1);
     $curtainColour->setBuynow(1);
     $em = $this->getDoctrine()->getEntityManager();
     $em->persist($curtainDesign);
     $em->persist($curtainColour);
     $em->flush();
     return new Response('Created curtain design id ' . $curtainDesign->getId() . ' Created curtain colour id ' . $curtainColour->getId());
 }
 protected function setUp()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     $this->em = static::$kernel->getContainer()->get('doctrine')->getEntityManager();
     $this->repository = static::$kernel->getContainer()->get('doctrine')->getRepository('ElmetSiteBundle:CurtainColour');
     $cpbRepository = static::$kernel->getContainer()->get('doctrine')->getRepository('ElmetSiteBundle:CurtainPriceBand');
     $curtainPriceBand = $cpbRepository->findOneById(2);
     $this->curtainDesign = new CurtainDesign();
     $this->curtainDesign->setCurtainPriceBand($curtainPriceBand);
     $this->curtainDesign->setUrlName("loretta");
     $this->curtainDesign->setCushionFinish("Corded");
     $this->curtainDesign->setEyeletsAvailable(1);
     $this->curtainDesign->setFabricWidth(140);
     $this->curtainDesign->setFinish("Fringed");
     $this->curtainDesign->setLined(1);
     $this->curtainDesign->setMaterials("Polyester/Cotton");
     $this->curtainDesign->setName("Lorretta Ready Made Curtains");
     $this->curtainDesign->setNew(1);
     $this->curtainDesign->setPatternRepeatLength(8.0);
     $this->curtainDesign->setTapeSize("3\"");
     $this->curtainDesign->setPosition("0");
     $this->curtainDesign->setDisplay("1");
     $this->curtainDesign->setSpecialPurchase("0");
     $curtainColour = new CurtainColour();
     $curtainColour->setName("Cream");
     $curtainColour->setFullFilepath("loretta/lorretta_cream.jpg");
     $curtainColour->setThumbnailFilepath("loretta/lorretta_cream_detail.jpg");
     $curtainColour->setSwatchFilepath("loretta/lorretta_cream_t.jpg");
     $curtainColour->setBuynow(1);
     $curtainColour->setInStock(1);
     $curtainColour->setAvailableStock(99.98999999999999);
     $curtainColour->setOnOffer(0);
     $curtainColour->setDisplay(1);
     $curtainColour->setPosition(1);
     $curtainColour->setCurtainDesign($this->curtainDesign);
     $this->curtainDesign->addCurtainColour($curtainColour);
     $secondCurtainColour = new CurtainColour();
     $secondCurtainColour->setName("Blue");
     $secondCurtainColour->setFullFilepath("loretta/lorretta_blue.jpg");
     $secondCurtainColour->setThumbnailFilepath("loretta/lorretta_blue_detail.jpg");
     $secondCurtainColour->setSwatchFilepath("loretta/lorretta_blue_t.jpg");
     $secondCurtainColour->setBuynow(1);
     $secondCurtainColour->setInStock(1);
     $secondCurtainColour->setAvailableStock(88.88);
     $secondCurtainColour->setOnOffer(0);
     $secondCurtainColour->setDisplay(1);
     $secondCurtainColour->setPosition(1);
     $secondCurtainColour->setCurtainDesign($this->curtainDesign);
     $this->curtainDesign->addCurtainColour($secondCurtainColour);
     $this->em->persist($this->curtainDesign);
     $this->em->flush();
 }
 public function createAction()
 {
     $id = $this->getRequest()->get('id');
     $repository = $this->getDoctrine()->getRepository('ElmetSiteBundle:CurtainDesign');
     $curtainDesign = $repository->findOneById($id);
     $curtainColour = new CurtainColour();
     $urlName = $curtainDesign->getUrlName();
     $displayFile = $this->getRequest()->files->get('display');
     $swatchFile = $this->getRequest()->files->get('swatch');
     $thumbFile = $this->getRequest()->files->get('thumbnail');
     $fileRoot = $this->container->getParameter('fileroot');
     $noImageFile = $this->container->getParameter('no_image_filename');
     if ($displayFile != null) {
         $curtainColour->setFullFilepath($urlName . "/" . $displayFile->getClientOriginalName());
         $displayFile->move($fileRoot . $urlName, $displayFile->getClientOriginalName());
     } else {
         $curtainColour->setFullFilepath($noImageFile);
     }
     if ($swatchFile != null) {
         $curtainColour->setSwatchFilepath($urlName . "/" . $swatchFile->getClientOriginalName());
         $swatchFile->move($fileRoot . $urlName, $swatchFile->getClientOriginalName());
     } else {
         $curtainColour->setSwatchFilepath($noImageFile);
     }
     if ($thumbFile != null) {
         $curtainColour->setThumbnailFilepath($urlName . "/" . $thumbFile->getClientOriginalName());
         $thumbFile->move($fileRoot . $urlName, $thumbFile->getClientOriginalName());
     } else {
         $curtainColour->setThumbnailFilepath($noImageFile);
     }
     $curtainColour->setName($this->getRequest()->get('name'));
     $curtainColour->setBuynow($this->getRequest()->get('buynow'));
     $curtainColour->setInStock($this->getRequest()->get('instock'));
     $curtainColour->setCurtainDesign($curtainDesign);
     $availableStock = $this->getRequest()->get('stock');
     if ($availableStock == null) {
         $curtainColour->setAvailableStock(0.0);
     } else {
         $curtainColour->setAvailableStock($availableStock);
     }
     if ($this->getRequest()->get('onDisplay') == null) {
         $curtainColour->setDisplay(1);
     } else {
         $curtainColour->setDisplay($this->getRequest()->get('onDisplay'));
     }
     $curtainColour->setOnOffer($this->getRequest()->get('onoffer'));
     if ($this->getRequest()->get('onoffer') == 1) {
         $curtainColour->setDiscountPercentage($this->getRequest()->get('discount'));
     } else {
         $curtainColour->setDiscountPercentage(0);
     }
     $curtainColour->setPosition($this->getRequest()->get('position'));
     $em = $this->getDoctrine()->getEntityManager();
     $em->persist($curtainColour);
     $em->flush();
     return $this->forward('ElmetAdminBundle:CurtainDesign:view', array('id' => $id));
 }