src/Entity/MediaGroupItem.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. use Doctrine\Common\Collections\Criteria;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\MediaGroupItemRepository")
  10.  */
  11. class MediaGroupItem
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="bigint")
  17.      */
  18.     private $id;
  19.     
  20.     /**
  21.      * @ORM\Version @ORM\Column(type="integer")
  22.      */
  23.     private $version;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $title;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $displayTitle;
  32.     /**
  33.      * @ORM\Column(type="text")
  34.      */
  35.     private $description;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  38.      * @ORM\JoinColumn(nullable=true)
  39.      */
  40.     private $media;
  41.     
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  44.      * @ORM\JoinColumn(nullable=true)
  45.      */
  46.     private $secondary_media;
  47.     
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  50.      * @ORM\JoinColumn(nullable=true)
  51.      */
  52.     private $french_media;
  53.     
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  56.      * @ORM\JoinColumn(nullable=true)
  57.      */
  58.     private $spanish_media;
  59.     
  60.     /**
  61.      * @ O R M\ManyToMany(targetEntity="MediaGroup", inversedBy="media")
  62.      * @ O R M\JoinTable(
  63.      *      name="media_group_media",
  64.      *      joinColumns={
  65.      *          @ORM\JoinColumn(name="media_id", referencedColumnName="id")
  66.      *      },
  67.      *      inverseJoinColumns={
  68.      *          @ORM\JoinColumn(name="media_group_id", referencedColumnName="id")
  69.      *      }
  70.      * )
  71.      * /
  72.     private $mediaGroup;
  73.     */
  74.     /**
  75.      * @ORM\Column(type="integer")
  76.      */
  77.     private $sort;
  78.     /**
  79.      * @ORM\Column(type="datetime")
  80.      */
  81.     private $modifiedAt;
  82.     /**
  83.      * @ORM\Column(type="datetime")
  84.      */
  85.     private $createdAt;
  86.     
  87.     /**
  88.      * @ORM\Column(type="datetime")
  89.      */
  90.     private $published_at;
  91.     
  92.     /**
  93.      * @ORM\Column(type="datetime", nullable=true)
  94.      */
  95.     private $expires_at;
  96.     /**
  97.      * @ORM\ManyToOne(targetEntity="App\Entity\MediaGroup", inversedBy="mediaGroupItems")
  98.      */
  99.     private $mediaGroup;
  100.     
  101.     /**
  102.      * @ORM\ManyToOne(targetEntity="App\Entity\Content", inversedBy="galleryMediaItems")
  103.      */
  104.     private $gallery;
  105.     /**
  106.      * @ORM\Column(type="integer")
  107.      */
  108.     private $status;
  109.     
  110.     /**
  111.      * @ORM\Column(type="integer")
  112.      */
  113.     private $total_impressions;
  114.     
  115.     /**
  116.      * @ORM\Column(type="integer")
  117.      */
  118.     private $total_clicks;
  119.     /**
  120.      * @ORM\Column(type="text")
  121.      */
  122.     private $attributes;
  123.     /**
  124.      * @ORM\Column(type="string", length=255)
  125.      */
  126.     private $external_url;
  127.     /**
  128.      * @ORM\Column(type="string", length=255)
  129.      */
  130.     private $youtube_url;
  131.     
  132.     /**
  133.      * @ORM\Column(type="string", length=255)
  134.      */
  135.     private $french_url;
  136.     
  137.     /**
  138.      * @ORM\Column(type="string", length=255)
  139.      */
  140.     private $spanish_url;
  141.     
  142.     /**
  143.      * @ORM\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="mediaGroupItems", cascade={"persist"})
  144.      */
  145.     private $customers;
  146.     
  147.     /**
  148.      * @ORM\OneToMany(targetEntity="App\Entity\Traffic", mappedBy="media_group_item", orphanRemoval=true, cascade={"persist", "remove"})
  149.      */
  150.     private $traffic;
  151.     
  152.     /**
  153.      * @ORM\OneToMany(targetEntity="App\Entity\AdImpression", mappedBy="media_group_item", orphanRemoval=true, cascade={"persist", "remove"})
  154.      */
  155.     private $impressions;
  156.     
  157.     /**
  158.      * @ORM\OneToMany(targetEntity="App\Entity\AdClick", mappedBy="media_group_item", orphanRemoval=true, cascade={"persist", "remove"})
  159.      */
  160.     private $clicks;
  161.     
  162.     /**
  163.      * @ORM\Column(type="datetime", nullable=true)
  164.      */
  165.     private $countdown;
  166.     
  167.     /**
  168.      * @ORM\OneToMany(targetEntity="App\Entity\AdAnalyticsDaily", mappedBy="media_group_item", orphanRemoval=true, cascade={"persist", "remove"})
  169.      */
  170.     private $ad_analytics_daily;
  171.     
  172.     
  173.     /**
  174.      * @ORM\ManyToMany(targetEntity="App\Entity\Site", inversedBy="media_group_items")
  175.      * @ORM\JoinTable(name="ad_site")
  176.      */
  177.     private $site;
  178.     /**
  179.      * @ORM\OneToOne(targetEntity="App\Entity\Poll", mappedBy="ad", cascade={"persist", "remove"})
  180.      */
  181.     private $poll;
  182.     /**
  183.      * @ORM\Column(type="integer")
  184.      */
  185.     private $question_slider;
  186.     /**
  187.      * @ORM\Column(type="integer")
  188.      */
  189.     private $site_default;
  190.     /**
  191.      * @ORM\OneToOne(targetEntity="App\Entity\Poll", inversedBy="popOutAd", cascade={"persist", "remove"})
  192.      */
  193.     private $popOutPoll;
  194.     // The pollOptions (pop-out) field is temporary until I can figure out how to properly display in SonataAdmin without this hack.
  195.     /**
  196.      * @ORM\OneToMany(targetEntity="App\Entity\PollOption", mappedBy="ad")
  197.      */
  198.     private $pollOptions;
  199.     
  200.     //The UUID of the mega menu item that this ad is pinned to.
  201.     /**
  202.      * @ORM\Column(type="string", length=150)
  203.      */
  204.     private $pinned_uuid;
  205.     /**
  206.      * @ORM\OneToMany(targetEntity="App\Entity\AdPin", mappedBy="media_group_item", orphanRemoval=true, cascade={"persist", "remove"})
  207.      */
  208.     private $pins;
  209.         /**
  210.      * @ORM\OneToMany(targetEntity="App\Entity\AdPriority", mappedBy="media_group_item", orphanRemoval=true, cascade={"persist", "remove"})
  211.      */
  212.     private $priorities;
  213.     /**
  214.      * @ORM\OneToMany(targetEntity="App\Entity\Content", mappedBy="popout_ad", orphanRemoval=true, cascade={"persist", "remove"})
  215.      */
  216.     private $popout_contents;
  217.     
  218.     public function __construct ()
  219.     {
  220.         
  221.         // $this->media_groups = new ArrayCollection();
  222.         $this->external_url "";
  223.         $this->french_url "";
  224.         $this->spanish_url "";
  225.         $this->attributes "";
  226.         $this->description "";
  227.         $this->title "";
  228.         $this->youtube_url "";
  229.         
  230.         $this->sort 0;
  231.         $this->status 1;
  232.         $this->total_impressions 0;
  233.         $this->total_clicks 0;
  234.         $this->modifiedAt = new \DateTime("now");
  235.         $this->createdAt = new \DateTime("now");
  236.         $this->published_at = new \DateTime("now");
  237.         
  238.         $this->customers = new ArrayCollection();
  239.         $this->site = new ArrayCollection();
  240.         $this->pollOptions = new ArrayCollection();
  241.         $this->question_slider 0;
  242.         $this->displayTitle "";
  243.         
  244.     }
  245.     
  246.     public function __clone() {
  247.         
  248.         $this->id null;
  249.         $this->title $this->title " - copy";
  250.         $this->displayTitle $this->displayTitle;
  251.         $this->status 0;
  252.         $this->total_impressions 0;
  253.         $this->total_clicks 0;
  254.         $this->customers = new ArrayCollection();
  255.         $this->modifiedAt = new \DateTime("now");
  256.         $this->createdAt = new \DateTime("now");
  257.         $this->published_at = new \DateTime("now");
  258.         
  259.     }
  260.     
  261.     public function getId()
  262.     {
  263.         return $this->id;
  264.     }
  265.     
  266.     public function getVersion() {
  267.         return $this->version;
  268.     }
  269.     
  270.     public function getTitle(): ?string
  271.     {
  272.         return $this->title;
  273.     }
  274.     public function setTitle(string $title null): self
  275.     {
  276.         $this->title $title $title "";
  277.         return $this;
  278.     }
  279.     
  280.     public function getDisplayTitle(): ?string
  281.     {
  282.         return $this->displayTitle;
  283.     }
  284.     public function setDisplayTitle(string $displayTitle null): self
  285.     {
  286.         $this->displayTitle $displayTitle $displayTitle "";
  287.         return $this;
  288.     }
  289.     public function getDescription(): ?string
  290.     {
  291.         return $this->description;
  292.     }
  293.     public function setDescription(string $description null): self
  294.     {
  295.         $this->description $description $description "";
  296.         return $this;
  297.     }
  298.     
  299.     //returns the description with a link if the ad includes a link
  300.     public function getDescriptionLink(string $target "_blank"): ?string
  301.     {
  302.         $return "";
  303.         if($this->getExternalUrl()) {
  304.             $return .= "<a href='"$this->getExternalUrl() ."' target='"$target ."' data-mitem-id='"$this->getId() ."'>";
  305.         }
  306.         
  307.         $return .= $this->description;
  308.         
  309.         if($this->getExternalUrl()) {
  310.             $return .= "</a>";
  311.         }
  312.         
  313.         return $return;
  314.     }
  315.     /*
  316.     public function getFile(): ?File
  317.     {
  318.         return $this->file;
  319.     }
  320.     public function setFile(?File $file): self
  321.     {
  322.         $this->file = $file;
  323.         return $this;
  324.     }
  325.     */
  326.     public function getModifiedAt(): ?\DateTimeInterface
  327.     {
  328.         return $this->modifiedAt;
  329.     }
  330.     public function setModifiedAt(\DateTimeInterface $modifiedAt): self
  331.     {
  332.         $this->modifiedAt $modifiedAt;
  333.         return $this;
  334.     }
  335.     public function getCreatedAt(): ?\DateTimeInterface
  336.     {
  337.         return $this->createdAt;
  338.     }
  339.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  340.     {
  341.         $this->createdAt $createdAt;
  342.         return $this;
  343.     }
  344.     
  345.     public function getPublishedAt(): ?\DateTimeInterface
  346.     {
  347.         return $this->published_at;
  348.     }
  349.     public function setPublishedAt(\DateTimeInterface $scheduled_for): self
  350.     {
  351.         $this->published_at $scheduled_for;
  352.         return $this;
  353.     }
  354.     
  355.     public function getExpiresAt(): ?\DateTimeInterface
  356.     {
  357.         return $this->expires_at;
  358.     }
  359.     public function setExpiresAt(?\DateTimeInterface $expires_at): self
  360.     {
  361.         $this->expires_at $expires_at;
  362.         return $this;
  363.     }
  364.     
  365.     public function getCountdown(): ?\DateTimeInterface
  366.     {
  367.         return $this->countdown;
  368.     }
  369.     public function setCountdown(?\DateTimeInterface $countdown): self
  370.     {
  371.         $this->countdown $countdown;
  372.         return $this;
  373.     }
  374.     public function getSort(): ?int
  375.     {
  376.         return $this->sort;
  377.     }
  378.     public function setSort(int $sort): self
  379.     {
  380.         $this->sort $sort;
  381.         return $this;
  382.     }
  383.     
  384.     /*
  385.     public function addMediaGroup (MediaGroup $mediaGroup)
  386.     {
  387.         if (!$this->media_groups->contains($mediaGroup)) {
  388.             $this->media_groups->add($mediaGroup);
  389.             $mediaGroup->addMedia($this);
  390.         }
  391.         
  392.         return $this;
  393.     }
  394.     
  395.     public function removeMediaGroup (MediaGroup $mediaGroup)
  396.     {
  397.         if ($this->media_groups->contains($mediaGroup)) {
  398.             $this->media_groups->removeElement($mediaGroup);
  399.             $mediaGroup->removeMedia($this);
  400.         }
  401.         
  402.         return $this;
  403.     }
  404.     */
  405.     
  406.     // Helper function for the admin page
  407.     public $mediaurl;
  408.     public function getMediaURL (): ?string
  409.     {
  410.         if($this->media) {
  411.             return $this->media->getURL();
  412.         }
  413.         return "";
  414.     }
  415.     
  416.     public function setMediaURL (): self
  417.     {
  418.         return $this;
  419.     }
  420.     
  421.     public function getFrenchMediaURL (): ?string
  422.     {
  423.         if($this->french_media) {
  424.             return $this->french_media->getURL();
  425.         }
  426.         return "";
  427.     }
  428.     
  429.     public function getSpanishMediaURL (): ?string
  430.     {
  431.         if($this->spanish_media) {
  432.             return $this->spanish_media->getURL();
  433.         }
  434.         return "";
  435.     }
  436.     public function getSecondaryMediaURL (): ?string
  437.     {
  438.         if($this->secondary_media) {
  439.             return $this->secondary_media->getURL();
  440.         }
  441.         return "";
  442.     }
  443.     
  444.     public function getMediaImageTag(string $class ""string $style ""string $target "")
  445.     {
  446.         $return "";
  447.         if($this->media) {
  448.             
  449.             if($this->getExternalUrl()) {
  450.                 $rel " rel='nofollow'";
  451.                 if(substr($this->getExternalUrl(), 01) == "/" || (isset($_SERVER['HTTP_HOST']) && (strpos($this->getExternalUrl(), $_SERVER['HTTP_HOST']) !== false) )) {
  452.                     $rel "";
  453.                 }
  454.                 
  455.                 $return .= "<a href='"$this->getExternalUrl() ."' target='"$target ."' data-mitem-id='"$this->getId() . "'" .$rel " >";
  456.             }
  457.             
  458.             if($this->french_media || $this->spanish_media) {
  459.                 $return .= $this->media->getImageTag($class" english_media"$style$this->getId(), $this->getExternalUrl());
  460.             }
  461.             else {
  462.                 $return .= $this->media->getImageTag($class$style$this->getId(), $this->getExternalUrl());
  463.             }
  464.             
  465.             $style .= "display:none;";
  466.             if($this->french_media) {
  467.                 $return .= $this->french_media->getImageTag($class." french_media secondary_media"$style$this->getId(), $this->getFrenchUrl());
  468.             }
  469.             if($this->spanish_media) {
  470.                 $return .= $this->spanish_media->getImageTag($class." spanish_media secondary_media"$style$this->getId(), $this->getSpanishUrl());
  471.             }
  472.             
  473.             if($this->getExternalUrl()) {
  474.                 $return .= "</a>";
  475.             }
  476.             
  477.         }
  478.         return $return;
  479.     }
  480.     
  481.     public function getMedia (): ?Media
  482.     {
  483.         return $this->media;
  484.     }
  485.     
  486.     public function setMedia (Media $media null): self
  487.     {
  488.         $this->media $media;
  489.         
  490.         return $this;
  491.     }
  492.     
  493.     public function getFrenchMedia (): ?Media
  494.     {
  495.         return $this->french_media;
  496.     }
  497.     
  498.     public function setFrenchMedia (Media $french_media null): self
  499.     {
  500.         $this->french_media $french_media;
  501.         
  502.         return $this;
  503.     }
  504.     
  505.     public function getSecondaryMedia (): ?Media
  506.     {
  507.         return $this->secondary_media;
  508.     }
  509.     
  510.     public function setSecondaryMedia (Media $secondary_media null): self
  511.     {
  512.         $this->secondary_media $secondary_media;
  513.         
  514.         return $this;
  515.     }
  516.     
  517.     public function getSpanishMedia (): ?Media
  518.     {
  519.         return $this->spanish_media;
  520.     }
  521.     
  522.     public function setSpanishMedia (Media $spanish_media null): self
  523.     {
  524.         $this->spanish_media $spanish_media;
  525.         
  526.         return $this;
  527.     }
  528.     public function getmediaGroup(): ?MediaGroup
  529.     {
  530.         return $this->mediaGroup;
  531.     }
  532.     public function setmediaGroup(?MediaGroup $mediaGroup): self
  533.     {
  534.         $this->mediaGroup $mediaGroup;
  535.         return $this;
  536.     }
  537.     
  538.     public function getGallery(): ?Content
  539.     {
  540.         $mGroup $this->getmediaGroup();
  541.         $mgContainers $mGroup->getMediaGroupContainers();
  542.         $mgContainer $mgContainers->first();
  543.         $gallery $mgContainer->getContent();
  544.         
  545.         return $gallery;
  546.     }
  547.     public function setGallery(?Content $gallery): self
  548.     {
  549.         $this->gallery $gallery;
  550.         return $this;
  551.     }
  552.     public function getStatus(): ?int
  553.     {
  554.         return $this->status;
  555.     }
  556.     public function setStatus(int $status): self
  557.     {
  558.         $this->status $status;
  559.         return $this;
  560.     }
  561.     
  562.     public function getTotalImpressions(): ?int
  563.     {
  564.         return $this->total_impressions;
  565.     }
  566.     
  567.     public function setTotalImpressions(int $total_impressions): self
  568.     {
  569.         $this->total_impressions $total_impressions;
  570.         
  571.         return $this;
  572.     }
  573.     
  574.     public function incrementTotalImpressions(): self
  575.     {
  576.         $this->total_impressions $this->total_impressions 1;
  577.         return $this;
  578.     }
  579.     
  580.     public function getTotalClicks(): ?int
  581.     {
  582.         return $this->total_clicks;
  583.     }
  584.     
  585.     public function setTotalClicks(int $total_clicks): self
  586.     {
  587.         $this->total_clicks $total_clicks;
  588.         
  589.         return $this;
  590.     }
  591.     
  592.     public function incrementTotalClicks(): self
  593.     {
  594.         $this->total_clicks $this->total_clicks 1;
  595.         return $this;
  596.     }
  597.     
  598.     public function isActive(): ?bool
  599.     {
  600.         return ($this->status == 1);
  601.     }
  602.     public function getAttributes(): ?string
  603.     {
  604.         return $this->attributes;
  605.     }
  606.     public function setAttributes(string $attributes null): self
  607.     {
  608.         $this->attributes $attributes $attributes "";
  609.         return $this;
  610.     }
  611.     
  612.     public function __toString () 
  613.     {
  614.         return $this->title $this->title "";
  615.     }
  616.     public function getExternalUrl(): ?string
  617.     {
  618.         return $this->external_url;
  619.     }
  620.     public function setExternalUrl(string $external_url null): self
  621.     {
  622.         $this->external_url $external_url $external_url "";
  623.         
  624.         return $this;
  625.     }
  626.     public function getYoutubeUrl(): ?string
  627.     {
  628.         return $this->youtube_url;
  629.     }
  630.     public function setYoutubeUrl(string $youtube_url null): self
  631.     {
  632.         $this->youtube_url $youtube_url $youtube_url "";
  633.         
  634.         return $this;
  635.     }
  636.     //Returns the YouTube video ID for video ads based on the URL
  637.     public function getYTVideoId() {
  638.         $url $this->youtube_url;
  639.         
  640.         $url_components parse_url($url);
  641.         if(array_key_exists("query"$url_components)) {
  642.             parse_str($url_components['query'], $params);
  643.             
  644.             if(array_key_exists("v"$params) && $params['v']) { //regular YT link
  645.                 return $params['v'];
  646.             }
  647.         }
  648.         else { //short 'share' YT link
  649.             if(strrpos($url'/')) {
  650.                 return substr($urlstrrpos($url'/') + 1);
  651.             }
  652.         }
  653.         //otherwise just return the URL (may have just posted the YT video ID)
  654.         return $url;
  655.     }
  656.     public function getFrenchUrl(): ?string
  657.     {
  658.         return $this->french_url;
  659.     }
  660.     public function setFrenchUrl(string $french_url null): self
  661.     {
  662.         $this->french_url $french_url $french_url "";
  663.         
  664.         return $this;
  665.     }
  666.     public function getSpanishUrl(): ?string
  667.     {
  668.         return $this->spanish_url;
  669.     }
  670.     public function setSpanishUrl(string $spanish_url null): self
  671.     {
  672.         $this->spanish_url $spanish_url $spanish_url "";
  673.         
  674.         return $this;
  675.     }
  676.     
  677.     
  678.     /**
  679.      * @return Collection|Customer[]
  680.      */
  681.     public function getCustomers(): Collection
  682.     {
  683.         return $this->customers;
  684.     }
  685.     
  686.     public function addCustomer(Customer $customer): self
  687.     {
  688.         if (!$this->customers->contains($customer)) {
  689.             $this->customers[] = $customer;
  690.             $customer->addMediaGroupItem($this);
  691.         }
  692.         return $this;
  693.     }
  694.     public function removeCustomer(Customer $customer): self
  695.     {
  696.         if ($this->customers->contains($customer)) {
  697.             $this->customers->removeElement($customer);
  698.             $customer->removeMediaGroupItem($this);
  699.         }
  700.         return $this;
  701.     }
  702.     
  703.     public function resetCustomers(): self
  704.     {
  705.         foreach($this->customers as $customer) {
  706.             $this->removeCustomer($customer);
  707.         }
  708.         return $this;
  709.     }
  710.     
  711.     
  712.     
  713.     /**
  714.      * @return Collection|Traffic[]
  715.      */
  716.     public function getTraffic(): Collection
  717.     {
  718.         return $this->traffic;
  719.     }
  720.     public function addTraffic(Traffic $traffic): self
  721.     {
  722.         if (!$this->traffic->contains($traffic)) {
  723.             $this->traffic[] = $traffic;
  724.             $traffic->setMediaGroupItem($this);
  725.         }
  726.         return $this;
  727.     }
  728.     public function removeTraffic(Traffic $traffic): self
  729.     {
  730.         if ($this->traffic->contains($traffic)) {
  731.             $this->traffic->removeElement($traffic);
  732.             // set the owning side to null (unless already changed)
  733.             if ($traffic->getMediaGroupItem() === $this) {
  734.                 $traffic->setMediaGroupItem(null);
  735.             }
  736.         }
  737.         return $this;
  738.     }
  739.     
  740.     public function getImpressions(): Collection
  741.     {
  742.         return $this->impressions;
  743.     }
  744.     
  745.     public function getClicks(): Collection
  746.     {
  747.         return $this->clicks;
  748.     }
  749.     
  750.     public function getAdAnalyticsDaily(): Collection
  751.     {
  752.         return $this->ad_analytics_daily;
  753.     }
  754.     public function getPins(): Collection
  755.     {
  756.         return $this->pins;
  757.     }
  758.     public function addPin(AdPin $pin): self
  759.     {
  760.         if (!$this->pins->contains($pin)) {
  761.             $this->pins[] = $pin;
  762.             $pin->setMediaGroupItem($this);
  763.         }
  764.         return $this;
  765.     }
  766.     
  767.     public function resetPins(): self
  768.     {
  769.         $this->pins = new ArrayCollection();
  770.         return $this;
  771.     }
  772.     
  773.     public function getPriorities(): Collection
  774.     {
  775.         return $this->priorities;
  776.     }
  777.     public function addPriority(AdPriority $priority): self
  778.     {
  779.         if (!$this->priorities->contains($priority)) {
  780.             $this->priorities[] = $priority;
  781.             $priority->setMediaGroupItem($this);
  782.         }
  783.         return $this;
  784.     }
  785.     
  786.     public function resetPriorities(): self
  787.     {
  788.         $this->priorities = new ArrayCollection();
  789.         return $this;
  790.     }
  791.     public function getPopoutContents(): Collection
  792.     {
  793.         return $this->popout_contents;
  794.     }
  795.     public function addPopoutContent(Content $content): self
  796.     {
  797.         if (!$this->popout_contents->contains($content)) {
  798.             $this->popout_contents[] = $content;
  799.             $content->setPopoutAd($this);
  800.         }
  801.         return $this;
  802.     }
  803.     
  804.     public function resetPopoutContents(): self
  805.     {
  806.         $this->popout_contents = new ArrayCollection();
  807.         return $this;
  808.     }
  809.     
  810.     
  811.     /**
  812.      * @return Collection|Site[]
  813.      */
  814.     public function getSite(): Collection
  815.     {
  816.         return $this->site;
  817.     }
  818.     
  819.     public function getSites(): Collection
  820.     {
  821.         return $this->site;
  822.     }
  823.     public function addSite(Site $site): self
  824.     {
  825.         if (!$this->site->contains($site)) {
  826.             $this->site[] = $site;
  827.             $site->addMediaGroupItem($this);
  828.         }
  829.         return $this;
  830.     }
  831.     
  832.     public function resetSite(): self
  833.     {
  834.         $this->site = new ArrayCollection();
  835.         return $this;
  836.     }
  837.     
  838.     public function removeSite(Site $site): self
  839.     {
  840.         if ($this->site->contains($site)) {
  841.             $this->site->removeElement($site);
  842.             $site->removeMediaGroupItem($this);
  843.         }
  844.         return $this;
  845.     }
  846.     
  847.     public function getSiteTextShort()
  848.       {
  849.           $site_texts = [];
  850.           foreach($this->getSite() as $s) {
  851.               $site_texts[] = $s->getSiteTextShort();
  852.           }
  853.           return implode(", "$site_texts);
  854.       }
  855.       
  856.       public function getSiteIds()
  857.       {
  858.           $site_ids = [];
  859.           foreach($this->getSite() as $s) {
  860.               $site_ids[] = $s->getId();
  861.           }
  862.           return $site_ids;
  863.       }
  864.     //Returns the front page poll that is using this ad
  865.     public function getPoll(): ?Poll
  866.     {
  867.         return $this->poll;
  868.     }
  869.     public function setPoll(?Poll $poll): self
  870.     {
  871.         $this->poll $poll;
  872.         return $this;
  873.     }
  874.     public function getPopOutPoll(): ?Poll
  875.     {
  876.         return $this->popOutPoll;
  877.     }
  878.     public function setPopOutPollPoll(?Poll $popOutPoll): self
  879.     {
  880.         $this->popOutPoll $popOutPoll;
  881.         return $this;
  882.     }
  883. /*
  884.     public function getPollOptions()
  885.     {
  886.         if($this->poll) {
  887.             return $this->poll->getPollOptions();
  888.         }
  889.         return null;
  890.     }
  891.     
  892.     public function setPollOptions(Collection $pollOptions)
  893.     {
  894.         if($this->poll) {
  895.             return $this->poll->setPollOptions($pollOptions);
  896.         }
  897.         return null;
  898.     }
  899.     public function addPollOption(PollOption $pollOption)
  900.     {
  901.         if($this->poll) {
  902.             return $this->poll->addPollOption($pollOption);
  903.         }
  904.         return null;
  905.     }
  906.     
  907.     public function removePollOption(PollOption $pollOption)
  908.     {
  909.         if($this->poll) {
  910.             return $this->poll->removePollOption($pollOption);
  911.         }
  912.         return null;
  913.     }
  914. */
  915.     
  916. /**
  917.      * @return Collection|PollOption[]
  918.      */
  919.     public function getPollOptions(): Collection
  920.     {
  921.         if($this->poll) {
  922.             $this->setPollOptions($this->poll->getPollOptions());
  923.         }
  924.         return $this->pollOptions;
  925.     }
  926.     public function setPollOptions (Collection $pollOptions): self {
  927.         foreach ($pollOptions as $pollOption) {
  928.             $this->addPollOption($pollOption);
  929.         }
  930.         return $this;
  931.     }
  932.     
  933.     public function addPollOption(PollOption $pollOption): self
  934.     {
  935.         if (!$this->pollOptions->contains($pollOption)) {
  936.             $this->pollOptions[] = $pollOption;
  937.             $pollOption->setAd($this);
  938.         }
  939.         if($this->poll) {
  940.             $this->poll->addPollOption($pollOption);
  941.         }
  942.         
  943.         return $this;
  944.     }
  945.     
  946.     public function removePollOption(PollOption $pollOption): self
  947.     {
  948.         if ($this->pollOptions->contains($pollOption)) {
  949.             $this->pollOptions->removeElement($pollOption);
  950.             // set the owning side to null (unless already changed)
  951.             if ($pollOption->getAd() === $this) {
  952.                 $pollOption->setAd(null);
  953.             }
  954.         }
  955.         if($this->poll) {
  956.             $this->poll->removePollOption($pollOption);
  957.         }
  958.         
  959.         return $this;
  960.     }
  961.     public function getQuestionSlider(): ?bool
  962.     {
  963.         return $this->question_slider == 1;
  964.     }
  965.     
  966.     public function setQuestionSlider(bool $value): self
  967.     {
  968.         $this->question_slider $value 0;
  969.         return $this;
  970.     }
  971.     public function getPinnedUuid(): ?string
  972.     {
  973.         return $this->pinned_uuid;
  974.     }
  975.     public function setPinnedUuid(string $pinned_uuid null): self
  976.     {
  977.         $this->pinned_uuid $pinned_uuid;
  978.         return $this;
  979.     }
  980.     public function getSiteDefault(): ?int
  981.     {
  982.         return $this->site_default;
  983.     }
  984.     public function setSiteDefault(int $site_default null): self
  985.     {
  986.         $this->site_default $site_default;
  987.         return $this;
  988.     }
  989.     /*
  990.     public function getImpressions($year=0, $month=0, $day=0)
  991.     {
  992.         $criteria = Criteria::create()
  993.             ->where(Criteria::expr()->eq("type", "4"))
  994.         ;
  995.         
  996.         return $this->getTraffic()->matching($criteria)->count();
  997.     }
  998.     
  999.     public function getClicks($year=0, $month=0, $day=0)
  1000.     {
  1001.         $criteria = Criteria::create()
  1002.             ->where(Criteria::expr()->eq("type", "5"))
  1003.         ;
  1004.         
  1005.         return $this->getTraffic()->matching($criteria)->count();
  1006.     }
  1007.     */
  1008.     
  1009. }