Ejemplo n.º 1
0
 private function generateTyped(InStreamVideoAd $ad, Api $adwords)
 {
     $fields = [];
     // Load class definitions
     $adwords->getService('AdGroupAdService');
     $video = new \Video();
     $video->mediaId = $ad->getVideoMediaId();
     $fields[] = new \TemplateElementField('video', 'VIDEO', null, $video);
     $banner = new \Image();
     $banner->mediaId = $ad->getCompanionBanner();
     $fields[] = new \TemplateElementField('companionBanner', 'IMAGE', null, $banner);
     return $fields;
 }
Ejemplo n.º 2
0
 /**
  * @Route("/campaigns/{campaignId}/adgroup/{adGroupId}/add", name="adwords_ad_add")
  * @param $campaignId
  * @param $adGroupId
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function adAddAction($campaignId, $adGroupId, Request $request)
 {
     $api = $this->adwords();
     $media = $api->loadMedia();
     $ad = new InStreamVideoAd(0, 'In stream Ad ' . date("Y-m-d H:i:s"), null, null);
     $ad->setDisplayUrl('www.easytobook.com');
     $ad->setFinalUrls(['http://www.easytobook.com/video']);
     $form = $this->createFormBuilder($ad)->add('name', TextType::class)->add('videoMediaId', ChoiceType::class, ['choices' => self::formatMediaChoices($media, 'Video')])->add('companionBanner', ChoiceType::class, ['choices' => self::formatMediaChoices($media, 'Image')])->add('displayUrl', TextType::class, [])->add('finalUrls', CollectionType::class, ['entry_type' => UrlType::class, 'allow_add' => true, 'allow_delete' => true])->add('save', SubmitType::class, array('label' => 'Add Ad'))->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $api->addTemplateAd($adGroupId, $ad);
         return $this->redirectToRoute("adwords_overview");
     }
     return $this->render('AppBundle:AdWords:adwords_add.html.twig', array('form' => $form->createView()));
 }