Пример #1
0
 /**
  * @param EntityManager $em
  * @param object $data
  * @param int $user_id
  * @return Advertisment
  */
 public static function addNewAdv(EntityManager $em, $data, $user_id)
 {
     $user = $em->find('NaidusvoeBundle:User', $user_id);
     $category = $em->getRepository('NaidusvoeBundle:AdvertismentCategory')->find($data->categoryID);
     $priceType = $em->getRepository('NaidusvoeBundle:PriceType')->find($data->priceType);
     $advType = $em->getRepository('NaidusvoeBundle:AdvertismentType')->find($data->typeID);
     $region = $em->getRepository('NaidusvoeBundle:Region')->find($data->region);
     $adv = new Advertisment();
     $adv->setUser($user);
     $adv->setDate(new \DateTime());
     $adv->setPrice($data->price);
     $adv->setPriceType($priceType);
     $adv->setType($advType);
     $adv->setCategory($category);
     $adv->setRegion($region);
     if ($data->subCategoryID) {
         $subCategory = $em->getRepository('NaidusvoeBundle:AdvertismentSubCategory')->find($data->subCategoryID);
         $adv->setSubCategory($subCategory);
     }
     $adv->setTitle($data->title);
     $adv->setDescription($data->description);
     $adv->setContactPerson($data->contactPerson);
     $adv->setEmail($data->email);
     $adv->setTelephoneNumber($data->telephoneNumber);
     $adv->setSkype($data->skype);
     $adv->setCity($data->city);
     return $adv;
 }
Пример #2
0
 private function generateDummyAdvs($count, $type)
 {
     $advs = [];
     for ($i = 0; $i < $count; $i++) {
         $newAdv = new Advertisment();
         $newAdv->setTitle('Ваша реклама');
         $attachment = new Attachment();
         $attachment->setImage('/resources/images/adv-default.png');
         $newAdv->addAttachment($attachment);
         $newAdv->setDescription('Тут може бути ваша реклама!');
         $newAdv->setDummy(true);
         $newAdv->setType($type);
         $advs[] = $newAdv;
     }
     return $advs;
 }