Пример #1
0
 protected function insertImage($object)
 {
     $faker = Faker::create();
     $placeImage = new PlaceImage();
     $img_name = $faker->md5 . '.jpg';
     $path = sys_get_temp_dir() . '/' . $img_name;
     file_put_contents($path, file_get_contents($faker->imageUrl(1280, 720)));
     $placeImage->setImage(new UploadedFile($path, $img_name, 'cafe', true));
     $object->setLogo($placeImage);
     return $object;
 }
Пример #2
0
 /**
  * @View()
  */
 public function postPlaceLogoActionold(Place $place)
 {
     $em = $this->getDoctrine()->getManager();
     $placeImage = new PlaceImage();
     $placeImage->setPlace($place);
     //TODO logo_id save in place table
     if ($place->getLogo()) {
         $placeImage = $place->getLogo();
     }
     $form = $this->createForm(LogoType::TYPE_NAME, $placeImage, ['method' => 'POST']);
     //var_dump($form->isValid(), $form->getErrorsAsString());die();
     //var_dump($this->getRequest()->request->all());
     if ($form->handleRequest($this->getRequest()) && $form->isValid()) {
         //$place->setLogo($placeImage);
         $em->persist($placeImage);
         $em->flush();
         return $this->getPlaceLogoAction($place);
     } else {
         return $form;
     }
 }
Пример #3
0
 /**
  * Add placeImages
  *
  * @param \Krombox\MainBundle\Entity\PlaceImage $placeImages
  * @return Place
  */
 public function addPlaceImage(\Krombox\MainBundle\Entity\PlaceImage $placeImages)
 {
     $this->placeImages[] = $placeImages;
     $placeImages->setPlace($this);
     return $this;
 }