src/Entity/Content.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use Symfony\Component\HttpFoundation\File\File as HttpFile;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\Common\Collections\Criteria;
  9. use App\Entity\SiteConfig;
  10. //use Doctrine\Common\Persistence\ObjectManagerAware;
  11. //use Doctrine\Common\Persistence\ObjectManager;
  12. //use Doctrine\Common\Persistence\Mapping\ClassMetadata;
  13. /**
  14.  * Content is the primary element of the website
  15.  * 
  16.  * @ORM\Entity(repositoryClass="App\Repository\ContentRepository")
  17.  * @Vich\Uploadable
  18.  */
  19. class Content /*implements ObjectManagerAware*/
  20. {
  21.     const STATIC_PAGE 0;
  22.     const PAGE 1;
  23.     const POST 2;
  24.     const CLASSIFIED 3;
  25.     const DIRECTORY 4;
  26.     const GALLERY 5;
  27.     const LANDING_PAGE 6;
  28.     const EVENT 7;
  29.     const WEBINAR 8;
  30.     const FORUM 9;
  31.     const FORUM_TOPIC 10;
  32.     const FORUM_REPLY 11;
  33.     const MODULE 12;
  34.     const HTML_AD 13;
  35.     const PROMOS_REBATES 14;
  36.     const THE_HUB 15//now known as RLW
  37.     const RLW 15;
  38.     const EVENT_ORGANIZER 16;
  39.     const EVENT_VENUE 17;
  40.     const PODCAST 18;
  41.     const EBOOK 19;
  42.     const CONTEST_GAMES 20;
  43.     
  44.     // only used for migrating the data over
  45.     const ACF_FIELD_GROUP 21;
  46.     const ACF_FIELD 22;
  47.     
  48.     // need to add these
  49.     const TRADE_ASSOCIATIONS 23;
  50.     
  51.     const THANK_YOU_LANDING_PAGE 24;
  52.     const AWARD 25;
  53.     const VIDEO 26;
  54.     const R_CLUB_PERK 27;
  55.     const SCHOLARSHIP 28;
  56.     
  57.     
  58.     const TEMPLATE_FULL_WIDTH 1;
  59.     const TEMPLATE_1_COL_SIDE 2;
  60.     const TEMPLATE_2_COL_SIDE 3
  61.     const TEMPLATE_3_COL_SIDE 4;
  62.     
  63.     const STATUS_SCHEDULED 2;
  64.     const STATUS_ACTIVE 1;
  65.     const STATUS_INACTIVE 0;
  66.     const STATUS_IN_REVIEW = -1;
  67.     const STATUS_EXPIRED = -2;
  68.     const STATUS_TRASH = -3;
  69.     const STATUS_SPAM = -4;
  70.     const STATUS_IN_CUSTOMER_REVIEW = -5;
  71.     
  72.     const SITE_RCS 1;
  73.     const SITE_AAR 2;
  74.     const SITE_MCS 3;
  75.     const SITE_CCS 4;
  76.     
  77.     /**
  78.      * @ORM\Id()
  79.      * @ORM\GeneratedValue()
  80.      * @ORM\Column(type="bigint")
  81.      */
  82.     private $id;
  83.     
  84.     /**
  85.      * @ORM\Version @ORM\Column(type="integer")
  86.      */
  87.     private $version;
  88.     
  89.     /**
  90.      * @ORM\ManyToOne(targetEntity="App\Entity\Content", inversedBy="children", cascade={"persist"})
  91.      * @ORM\JoinColumn(nullable=true)
  92.      */
  93.     private $prnt;
  94.     
  95.     /**
  96.      * @ORM\OneToMany(targetEntity="App\Entity\Content", mappedBy="prnt")
  97.      * @ORM\OrderBy({"published_at" = "DESC"})
  98.      */
  99.     private $children;
  100.     
  101.     /**
  102.      * @Vich\UploadableField(mapping="content_images", fileNameProperty="featured_image")
  103.      * @var File
  104.      */
  105.     private $featured_image_data;
  106.     
  107.     
  108.     /**
  109.      * @ORM\Column(type="string", length=255)
  110.      */
  111.     private $featured_image;
  112.     
  113.     /**
  114.      * @ORM\Column(type="string", length=255)
  115.      */
  116.     private $media_url;
  117.     /**
  118.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  119.      * @ORM\JoinColumn(nullable=true)
  120.      */
  121.     private $media;
  122.     
  123.     /**
  124.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  125.      * @ORM\JoinColumn(nullable=true)
  126.      */
  127.     private $dummy_media//In sonata admin, can't have multiple ModelListType fields of the same type... even if one is unmapped
  128.     //Delete this as soon as it's fixed, really don't want this here as it adds a field to the database
  129.     
  130.     /**
  131.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  132.      * @ORM\JoinColumn(nullable=true)
  133.      */
  134.     private $video_media;
  135.     
  136.     /**
  137.      * @ORM\ManyToMany(targetEntity="App\Entity\Site", inversedBy="content")
  138.      */
  139.     private $site;
  140.     
  141.     /**
  142.      * @ORM\Column(type="integer")
  143.      */
  144.     private $type;
  145.     
  146.     /**
  147.      * @ORM\Column(type="string", length=128)
  148.      */
  149.     private $template;
  150.     
  151.     /**
  152.      * @ORM\Column(type="string", length=255)
  153.      */
  154.     private $title;
  155.     
  156.     /**
  157.      * @ORM\Column(type="string", length=255)
  158.      */
  159.     private $slug;
  160.     
  161.     /**
  162.      * @ORM\Column(type="integer")
  163.      */
  164.     private $searchable;
  165.     
  166.     /**
  167.      * @ORM\Column(type="integer")
  168.      */
  169.     private $exclude_from_list;
  170.     
  171.     /**
  172.      * @ORM\Column(type="integer")
  173.      */
  174.     private $permission;
  175.     
  176.     /**
  177.      * @ORM\Column(type="integer")
  178.      */
  179.     private $status;
  180.     
  181.     /**
  182.      * @ORM\Column(type="integer")
  183.      */
  184.     private $members_only;
  185.     /**
  186.      * @ORM\Column(type="integer")
  187.      */
  188.     private $include_author_byline;
  189.     /**
  190.      * @ORM\Column(type="integer")
  191.      */
  192.     private $include_author_bio;
  193.     /**
  194.      * @ORM\Column(type="integer")
  195.      */
  196.     private $include_customer_call_to_action;
  197.     /**
  198.      * @ORM\Column(type="integer")
  199.      */
  200.     private $include_customer_bio;
  201.     
  202.     /**
  203.      * @ORM\Column(type="integer")
  204.      */
  205.     private $total_impressions;
  206.     
  207.     /**
  208.      * @ORM\Column(type="integer")
  209.      */
  210.     private $total_clicks;
  211.     
  212.     /**
  213.      * @ORM\Column(type="datetime")
  214.      */
  215.     private $published_at;
  216.     
  217.     /**
  218.      * @ORM\Column(type="datetime")
  219.      */
  220.     private $modified_at;
  221.     
  222.     /**
  223.      * @ORM\Column(type="datetime")
  224.      */
  225.     private $created_at;
  226.     
  227.     /**
  228.      * @ORM\Column(type="text")
  229.      */
  230.     private $content_intro;
  231.     
  232.     /**
  233.      * @ORM\Column(type="text")
  234.      */
  235.     private $content_full;
  236.     
  237.     /**
  238.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="content")
  239.      * @ORM\JoinColumn(name="author_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  240.      */
  241.     private $author;
  242.     
  243.     /**
  244.      * @ORM\OneToMany(targetEntity="App\Entity\ContentMeta", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  245.      * @ O R M\JoinColumn(name="content_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  246.      * 
  247.      * I must be using onDeleteCascade incorrectly... - setting from the child now - see if works
  248.      */
  249.     private $contentmeta;
  250.     
  251.     /**
  252.      * @ORM\Column(type="string", length=255)
  253.      */
  254.     private $meta_description;
  255.     
  256.     /**
  257.      * @ORM\Column(type="string", length=255)
  258.      */
  259.     private $meta_keywords;
  260.     
  261.     /**
  262.      * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="content")
  263.      */
  264.     private $category;
  265.     
  266.     /**
  267.      * Instead of referencing all content - there are more specific content properties below...
  268.      * 
  269.      * @ O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="content")
  270.      * /
  271.     private $customers;
  272.     */
  273.     
  274.     /**
  275.      * @O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="promos_rebates_contests")
  276.      * /
  277.     private $customers_promos_rebates_contests;
  278.     /**
  279.      * @O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="hub_content")
  280.      * /
  281.     private $customers_hub_content;
  282.     /**
  283.      * @O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="coffee_shop_news")
  284.      * /
  285.     private $customers_coffee_shop_news;
  286.     */
  287.     
  288.     /**
  289.      * The secondary categories should contain ALL the categories assigned to the content object.
  290.      * @ORM\ManyToMany(targetEntity="App\Entity\Category", inversedBy="secondary_content")
  291.      */
  292.     private $secondary_categories;
  293.     
  294.     /**
  295.      * @ORM\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="contents", cascade={"persist"})
  296.      */
  297.     private $customers;
  298.     /**
  299.      * @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="primaryContents")
  300.      */
  301.     private $primaryCustomer;
  302.     
  303.     /**
  304.      * @ O R M\ManyToMany(targetEntity="App\Entity\Content", inversedBy="main_content")
  305.      * @O R M\JoinTable(name="content_content",
  306.      *      joinColumns={@ORM\JoinColumn(name="content_id", referencedColumnName="id")},
  307.      *      inverseJoinColumns={@ORM\JoinColumn(name="related_content_id", referencedColumnName="id")}
  308.      *      )
  309.      * /
  310.     protected $related_contents;
  311.     */
  312.     /**
  313.      * @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="content", orphanRemoval=true)
  314.      * @ORM\OrderBy({"created_at" = "ASC"})
  315.      */
  316.     private $comments;
  317.     
  318.     /**
  319.      * @ORM\Column(type="text")
  320.      */
  321.     private $content_builder;
  322.     /**
  323.      * @ORM\OneToMany(targetEntity="App\Entity\PurchaseItem", mappedBy="content")
  324.      * @ORM\OrderBy({"purchase_date" = "DESC"})
  325.      */
  326.     private $purchase_items;
  327.     /**
  328.      * @ORM\Column(type="boolean")
  329.      */
  330.     private $showTitle;
  331.     /**
  332.      * @ORM\Column(type="integer", nullable=true)
  333.      */
  334.     private $old_id;
  335.     /**
  336.      * @ORM\Column(type="integer")
  337.      */
  338.     private $featured;
  339.     
  340.     /**
  341.      * @ORM\Column(type="integer")
  342.      */
  343.     private $announcement;
  344.     
  345.     /**
  346.      * @ORM\Column(type="string", length=100)
  347.      */
  348.     private $announcement_sites;
  349.     
  350.     /**
  351.      * @ORM\Column(type="datetime", nullable=true)
  352.      */
  353.     private $expires_at;
  354.     
  355.     /**
  356.      * @ORM\OneToMany(targetEntity="App\Entity\Traffic", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  357.      */
  358.     private $traffic;
  359.     
  360.     /**
  361.      * @ORM\OneToMany(targetEntity="App\Entity\ContentImpression", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  362.      */
  363.     private $impressions;
  364.     
  365.     /**
  366.      * @ORM\OneToMany(targetEntity="App\Entity\ContentView", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  367.      */
  368.     private $views;
  369.     
  370.     /**
  371.      * @ORM\OneToMany(targetEntity="App\Entity\ContentLinkClick", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  372.      */
  373.     private $link_clicks;
  374.     
  375.     /**
  376.      * @ORM\OneToMany(targetEntity="App\Entity\Lead", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  377.      */
  378.     private $leads;
  379.     
  380.     /**
  381.      * @ORM\OneToOne(targetEntity="App\Entity\Customer", mappedBy="directory_content", cascade={"persist"})
  382.      */
  383.     private $directory;
  384.     
  385.     
  386.     /**
  387.      * @ORM\ManyToMany(targetEntity="App\Entity\MediaGroup", inversedBy="contents", cascade={"persist"})
  388.      */
  389.     private $media_groups;
  390.     
  391.     /* *
  392.      * @O R M\ManyToMany(targetEntity="App\Entity\MediaGroupContainer", inversedBy="contents", cascade={"persist"})
  393.      * /
  394.     private $media_group_containers;
  395.     */
  396.     
  397.     /**
  398.      * @ORM\OneToMany(targetEntity="App\Entity\MediaGroupContainer", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  399.      */
  400.     private $media_group_containers;
  401.     
  402.     /**
  403.      * @ORM\OneToMany(targetEntity="App\Entity\MediaGroupItem", mappedBy="gallery", orphanRemoval=true, cascade={"persist", "remove"})
  404.      * @ORM\OrderBy({"sort" = "ASC"})
  405.      */
  406.     private $galleryMediaItems;
  407.     
  408.     /**
  409.      * @ORM\ManyToOne(targetEntity="App\Entity\Form", cascade={"persist"})
  410.      * @ORM\JoinColumn(nullable=true)
  411.      */
  412.     private $form;
  413.     
  414.     /**
  415.      * @ORM\OneToMany(targetEntity="App\Entity\ContentAnalyticsDaily", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  416.      */
  417.     private $content_analytics_daily;
  418.     
  419.     /**
  420.      * @ORM\OneToMany(targetEntity="App\Entity\ContentAnalyticsCorrectionDaily", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  421.      */
  422.     private $content_analytics_correction_daily;
  423.     /**
  424.      * @ORM\ManyToOne(targetEntity="App\Entity\MediaGroupItem", inversedBy="popout_contents", cascade={"persist"})
  425.      * @ORM\JoinColumn(name="popout_ad_id", referencedColumnName="id")
  426.      */
  427.     private $popout_ad;
  428.     
  429.     /**
  430.      * @ORM\ManyToMany(targetEntity="App\Entity\HootsuiteSocialProfile", inversedBy="contents")
  431.      */
  432.     private $hootsuite_social_profiles;
  433.     /**
  434.      * @ORM\Column(type="text")
  435.      */
  436.     private $hootsuite_content;
  437.     /**
  438.      * @ORM\Column(type="text")
  439.      */
  440.     private $hootsuite_facebook_content;
  441.     /**
  442.      * @ORM\Column(type="text")
  443.      */
  444.     private $hootsuite_twitter_content;
  445.     /**
  446.      * @ORM\Column(type="text")
  447.      */
  448.     private $hootsuite_linkedin_content;
  449.     /**
  450.      * @ORM\Column(type="integer")
  451.      */
  452.     private $hootsuite_to_publish;
  453.     /**
  454.      * @ORM\Column(type="integer")
  455.      */
  456.     private $hootsuite_use_post_media;
  457.     
  458.     /**
  459.      * @ORM\Column(type="integer")
  460.      */
  461.     private $hootsuite_use_post_published_at;
  462.     /**
  463.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  464.      * @ORM\JoinColumn(nullable=true)
  465.      */
  466.     private $hootsuite_media;
  467.     /**
  468.      * @ORM\Column(type="datetime", nullable=true)
  469.      */
  470.     private $hootsuite_published_at;
  471.     /**
  472.      * @ORM\OneToMany(targetEntity="App\Entity\HootsuiteMessage", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
  473.      */
  474.     private $hootsuite_messages;
  475.     
  476.     public function __construct()
  477.     {
  478.         $this->title "";
  479.         $this->showTitle 1;
  480.         
  481.         //$this->site = SELF::SITE_RCS;
  482.         $this->site = new ArrayCollection();
  483.         
  484.         $this->type 1;
  485.         $this->status SELF::STATUS_INACTIVE;
  486.         $this->members_only 0;
  487.         $this->include_author_byline 0;
  488.         $this->include_author_bio 1;
  489.         $this->include_customer_call_to_action 1;
  490.         $this->include_customer_bio 1;
  491.         $this->total_impressions 0;
  492.         $this->total_clicks 0;
  493.         $this->template 2;
  494.         $this->searchable 1;
  495.         $this->exclude_from_list 0;
  496.         $this->permission 0;
  497.         $this->slug "";
  498.         $this->content_intro "";
  499.         $this->content_full "";
  500.         
  501.         $this->published_at = new \DateTime();
  502.         $this->modified_at = new \DateTime();
  503.         $this->created_at = new \DateTime ();
  504.         
  505.         $this->meta_description "";
  506.         $this->meta_keywords "";
  507.         $this->content_builder "";
  508.         
  509.         $this->show_title 0;
  510.         $this->old_id 0;
  511.         $this->featured 0;
  512.         $this->announcement 0;
  513.         $this->announcement_sites "";
  514.         
  515.         $this->contentmeta = new ArrayCollection();
  516.         
  517.         $this->featured_image "";
  518.         
  519.         /* Multiple?
  520.         $this->categories = new ArrayCollection();
  521.         */
  522.         /*
  523.         $this->customers_promos_rebates_contests = new ArrayCollection();
  524.         $this->customers_hub_content = new ArrayCollection();
  525.         $this->customers_coffee_shop_news = new ArrayCollection();
  526.         */
  527.         
  528.         $this->customers = new ArrayCollection();
  529.         $this->secondary_categories = new ArrayCollection();
  530.         $this->children = new ArrayCollection();
  531.         $this->comments = new ArrayCollection();
  532.         $this->purchase_items = new ArrayCollection();
  533.         $this->media_group_containers = new ArrayCollection();
  534.         $this->media_groups = new ArrayCollection();
  535.         $this->hootsuite_social_profiles = new ArrayCollection();
  536.         $this->hootsuite_messages = new ArrayCollection();
  537.         $this->hootsuite_content "";
  538.         $this->hootsuite_facebook_content "";
  539.         $this->hootsuite_twitter_content "";
  540.         $this->hootsuite_linkedin_content "";
  541.         $this->hootsuite_to_publish 0;
  542.         $this->hootsuite_use_post_media 1;
  543.         $this->hootsuite_use_post_published_at 1;
  544.         
  545.     }
  546.     
  547.     public function __clone() {
  548.         
  549.         $this->id null;
  550.         $this->title $this->title " - copy";
  551.         $this->slug $this->slug "-copy";
  552.         $this->status self::STATUS_INACTIVE;
  553.         $this->total_impressions 0;
  554.         $this->total_clicks 0;
  555.         $this->customers = new ArrayCollection();
  556.         $this->contentmeta = new ArrayCollection();
  557.         
  558.         $this->media_group_containers = new ArrayCollection();
  559.         $this->media_groups = new ArrayCollection();
  560.         
  561.         $this->published_at = new \DateTime();
  562.         $this->modified_at = new \DateTime();
  563.         $this->created_at = new \DateTime ();
  564.         
  565.     }
  566.     
  567.     /*
  568.     //Removing interface after update 2021/08/04
  569.     //Doesn't seem to be in use anyway
  570.     public function injectObjectManager(
  571.         ObjectManager $objectManager,
  572.         ClassMetadata $classMetadata
  573.     ) {
  574.         $this->em = $objectManager;
  575.     }
  576.     */
  577.     
  578.     public function getFeaturedImageData(): ?HttpFile
  579.     {
  580.         return $this->featured_image_data;
  581.     }
  582.     
  583.     public function setFeaturedImageData(HttpFile $data null): self
  584.     {
  585.         /* prevent nulls - ... we want nulls
  586.         if (!$data) {
  587.             $data = "";
  588.         }
  589.         */
  590.         
  591.         if ($data == null) {
  592.             if ($this->featured_image) {
  593.                 $this->removeFeaturedImage();
  594.             }
  595.         } 
  596.         
  597.         
  598.         $this->featured_image_data $data;
  599.         $this->modified_at = new \DateTime("now");
  600.         
  601.         /*
  602.         if ($data) {
  603.             // $this->extension = $data->guessExtension();
  604.             // $this->type = $data->getMimeType();
  605.             $this->modified_at = new \DateTime("now");
  606.         }
  607.         */
  608.         return $this;
  609.     }
  610.     
  611.     public function removeFeaturedImage ()
  612.     {
  613.         $file $this->featured_image;
  614.         
  615.         if ($file) {
  616.             // can't find an easy way to remove the image right away - simple hack should work...
  617.             $file dirname(dirname(dirname(__FILE__)))."/public/uploads/content/{$file}";
  618.             if (file_exists($file)) {
  619.                 unlink($file);
  620.             }
  621.             $this->featured_image "";
  622.             $this->featured_image_data null;
  623.         }
  624.     }
  625.     
  626.     public function getFeaturedImage(): ?string
  627.     {
  628.         return $this->featured_image;
  629.     }
  630.     
  631.     public function setFeaturedImage(string $image null): self
  632.     {        
  633.         // prevent nulls
  634.         if (!$image) {
  635.             $image "";
  636.         }
  637.         
  638.         $this->featured_image $image;
  639.         return $this;
  640.     }
  641.     
  642.     public function getFeaturedImageURL ()
  643.     {
  644.         if($this->media) {
  645.             return $this->media->getURL();
  646.         }
  647.         elseif ($this->featured_image) {
  648.             return "/uploads/content/{$this->featured_image}";
  649.         }
  650.         return "";
  651.     }
  652.     
  653.     public function getFeaturedImageTag ($class ""$style "")
  654.     {
  655.         if($this->getType() == && $this->getDirectory()) {
  656.             if($this->getDirectory()->getMedia()) {
  657.                 return $this->getDirectory()->getMedia()->getImageTag($class$style);
  658.             }
  659.         }
  660.         elseif($this->media) {
  661.             return $this->media->getImageTag($class$style);
  662.         }
  663.         
  664.         return "";
  665.     }
  666.     
  667.     public function hasVideoMedia() {
  668.         return $this->video_media true false;
  669.     }
  670.     
  671.     public function getVideoMediaURL ()
  672.     {
  673.         if($this->video_media) {
  674.             return $this->video_media->getURL();
  675.         }
  676.         return "";
  677.     }
  678.     
  679.     public function getVideoMediaTag ($class ""$style ""$autoplay false$controls true$muted false$thumbnailUrl="")
  680.     {
  681.         if($this->video_media) {
  682.             return $this->video_media->getVideoTag($class$style""""true$autoplay$controls$muted$thumbnailUrl);
  683.         }
  684.         else {
  685.             $this->getFeaturedImageTag($class$style);
  686.         }
  687.         
  688.         return "";
  689.     }
  690.     
  691.     public function getMediaURL ()
  692.     {
  693.         return $this->media_url;
  694.     }
  695.     
  696.     public function setMediaURL ($url)
  697.     {
  698.         $this->media_url $url;
  699.         
  700.         return $this;
  701.     }
  702.     public function getMedia (): ?Media
  703.     {
  704.         return $this->media;
  705.     }
  706.     
  707.     public function setMedia (Media $media null): self
  708.     {
  709.         $this->media $media;
  710.         
  711.         return $this;
  712.     }
  713.     
  714.     public function getDummyMedia (): ?Media
  715.     {
  716.         return $this->dummy_media;
  717.     }
  718.     
  719.     public function setDummyMedia (Media $dummy_media null): self
  720.     {
  721.         $this->dummy_media $dummy_media;
  722.         
  723.         return $this;
  724.     }
  725.     
  726.     public function getVideoMedia (): ?Media
  727.     {
  728.         return $this->video_media;
  729.     }
  730.     
  731.     public function setVideoMedia (Media $video_media null): self
  732.     {
  733.         $this->video_media $video_media;
  734.         
  735.         return $this;
  736.     }
  737.     
  738.     public function getId ()
  739.     {
  740.         return $this->id;
  741.     }
  742.     
  743.     public function getVersion() {
  744.         return $this->version;
  745.     }
  746.     public function setVersion(int $version): self
  747.     {
  748.         $this->version $version;
  749.         return $this;
  750.     }
  751.     public function decrementVersion()
  752.     {
  753.         $this->version $this->version 1;
  754.     }
  755.     
  756.     public function getPrnt(): ?self
  757.     {
  758.         return $this->prnt;
  759.     }
  760.     public function setPrnt(self $parent null): self
  761.     {
  762.         $this->prnt $parent;
  763.         return $this;
  764.     }
  765.     
  766.     /*
  767.     public function getSite(): ?int
  768.     {
  769.         return $this->site;
  770.     }
  771.     
  772.     public function setSite(int $site): self
  773.     {
  774.         $this->site = $site;
  775.         return $this;
  776.     }
  777.     
  778.     public function getSiteTextShort()
  779.     {
  780.         $site = $this->getSite();
  781.         if($site) {
  782.             switch($site) {
  783.                 case SELF::SITE_RCS:
  784.                     return "RCS";
  785.                 case SELF::SITE_AAR:
  786.                     return "AAR";
  787.             }
  788.         }
  789.         return "";
  790.     }
  791.     */
  792.     
  793.     /**
  794.      * @return Collection|Site[]
  795.      */
  796.     public function getSite(): Collection
  797.     {
  798.         return $this->site;
  799.     }
  800.     
  801.     public function getSites(): Collection
  802.     {
  803.         return $this->site;
  804.     }
  805.     
  806.     public function setSites($sites)
  807.     {
  808.         $this->site $sites;
  809.         return $this;
  810.     }
  811.     
  812.     public function addSite(Site $site): self
  813.     {
  814.         if (!$this->site->contains($site)) {
  815.             $this->site[] = $site;
  816.             $site->addContent($this);
  817.         }
  818.         return $this;
  819.     }
  820.     
  821.     public function resetSite(): self
  822.     {
  823.         $this->site = new ArrayCollection();
  824.         return $this;
  825.     }
  826.     
  827.     public function removeSite(Site $site): self
  828.     {
  829.         if ($this->site->contains($site)) {
  830.             $this->site->removeElement($site);
  831.             $site->removeContent($this);
  832.         }
  833.         return $this;
  834.     }
  835.     
  836.     
  837.     public function getSiteTextShort()
  838.     {
  839.         $site_texts = [];
  840.         foreach($this->getSites() as $s) {
  841.             $site_texts[] = $s->getSiteTextShort();
  842.         }
  843.         return implode(", "$site_texts);
  844.     }
  845.     
  846.     public function getSiteIds()
  847.     {
  848.         $site_ids = [];
  849.         foreach($this->getSites() as $s) {
  850.             $site_ids[] = $s->getId();
  851.         }
  852.         return $site_ids;
  853.     }
  854.     
  855.     public function getType(): ?int
  856.     {
  857.         return $this->type;
  858.     }
  859.     
  860.     public static function getTypeTextStatic($type)
  861.     {
  862.         switch ($type) {
  863.             case self::STATIC_PAGE:
  864.                 return "Static Page";
  865.             case self::PAGE:
  866.                 return "Page";
  867.                 
  868.             case self::POST:
  869.                 return "Post";
  870.                 
  871.             case self::CLASSIFIED:
  872.                 return "Classified Listing";
  873.                 
  874.             case self::DIRECTORY:
  875.                 return "Directory Listing";
  876.                 
  877.             case self::GALLERY:
  878.                 return "Gallery";
  879.                 
  880.             case self::LANDING_PAGE:
  881.                 return "Landing Page";
  882.                 
  883.             case self::EVENT:
  884.                 return "Event";
  885.                 
  886.             case self::WEBINAR:
  887.                 return "Webinar";
  888.                 
  889.             case self::FORUM:
  890.                 return "Forum";
  891.                 
  892.             case self::FORUM_TOPIC:
  893.                 return "Forum Topic";
  894.                 
  895.             case self::FORUM_REPLY:
  896.                 return "Forum Reply";
  897.                 
  898.             case self::MODULE:
  899.                 return "Module";
  900.             
  901.             case self::HTML_AD:
  902.                 return "HTML Ad";
  903.                 
  904.             case self::PROMOS_REBATES:
  905.                 return "Promos and Rebates";
  906.                 
  907.             case self::THE_HUB:
  908.                 return "Read Listen Watch";
  909.             
  910.             case self::EVENT_ORGANIZER:
  911.                 return "Event Organizer";
  912.                 
  913.             case self::EVENT_VENUE:
  914.                 return "Event Venue";
  915.                 
  916.             case self::PODCAST:
  917.                 return "Podcast";
  918.                 
  919.             case self::EBOOK:
  920.                 return "Ebook";
  921.                 
  922.             case self::CONTEST_GAMES:
  923.                 return "Contests and Games";
  924.                 
  925.             case self::TRADE_ASSOCIATIONS:
  926.                 return "Trade Associations";    
  927.             
  928.             case self::THANK_YOU_LANDING_PAGE:
  929.                 return "Thank You Page";  
  930.                 
  931.             case self::AWARD:
  932.                 return "Award";
  933.                 
  934.             case self::VIDEO:
  935.                 return "Video";
  936.                 
  937.             case self::R_CLUB_PERK:
  938.                 return "R-Club Perk";
  939.                 
  940.             case self::SCHOLARSHIP:
  941.                 return "Scholarship";
  942.         }
  943.         
  944.         return "Content";
  945.     }
  946.     
  947.     public function getTypeText()
  948.     {
  949.         switch ($this->type) {
  950.             case self::STATIC_PAGE:
  951.                 return "Static Page";
  952.             case self::PAGE:
  953.                 return "Page";
  954.                 
  955.             case self::POST:
  956.                 return "Post";
  957.                 
  958.             case self::CLASSIFIED:
  959.                 return "Classified Listing";
  960.                 
  961.             case self::DIRECTORY:
  962.                 return "Directory Listing";
  963.                 
  964.             case self::GALLERY:
  965.                 return "Gallery";
  966.                 
  967.             case self::LANDING_PAGE:
  968.                 return "Landing Page";
  969.                 
  970.             case self::EVENT:
  971.                 return "Event";
  972.                 
  973.             case self::WEBINAR:
  974.                 return "Webinar";
  975.                 
  976.             case self::FORUM:
  977.                 return "Forum";
  978.                 
  979.             case self::FORUM_TOPIC:
  980.                 return "Forum Topic";
  981.                 
  982.             case self::FORUM_REPLY:
  983.                 return "Forum Reply";
  984.                 
  985.             case self::MODULE:
  986.                 return "Module";
  987.             
  988.             case self::HTML_AD:
  989.                 return "HTML Ad";
  990.                 
  991.             case self::PROMOS_REBATES:
  992.                 return "Promos and Rebates";
  993.                 
  994.             case self::THE_HUB:
  995.                 return "Read Listen Watch";
  996.             
  997.             case self::EVENT_ORGANIZER:
  998.                 return "Event Organizer";
  999.                 
  1000.             case self::EVENT_VENUE:
  1001.                 return "Event Venue";
  1002.                 
  1003.             case self::PODCAST:
  1004.                 return "Podcast";
  1005.                 
  1006.             case self::EBOOK:
  1007.                 return "Ebook";
  1008.                 
  1009.             case self::CONTEST_GAMES:
  1010.                 return "Contests and Games";
  1011.                 
  1012.             case self::TRADE_ASSOCIATIONS:
  1013.                 return "Trade Associations";    
  1014.             
  1015.             case self::THANK_YOU_LANDING_PAGE:
  1016.                 return "Thank You Page";
  1017.                 
  1018.             case self::AWARD:
  1019.                 return "Award";
  1020.                 
  1021.             case self::VIDEO:
  1022.                 return "Video";
  1023.                 
  1024.             case self::R_CLUB_PERK:
  1025.                 return "R-Club Perk";
  1026.                 
  1027.             case self::SCHOLARSHIP:
  1028.                 return "Scholarship";
  1029.         }
  1030.         
  1031.         return "Content";
  1032.     }
  1033.     
  1034.     public function getTypeString ()
  1035.     {
  1036.         return $this->getTypeText();
  1037.     }
  1038.     public function setType(int $type): self
  1039.     {
  1040.         $this->type $type;
  1041.         return $this;
  1042.     }
  1043.     public function getTemplate(): ?string
  1044.     {
  1045.         return $this->template;
  1046.     }
  1047.     public function setTemplate(string $template): self
  1048.     {
  1049.         $this->template $template;
  1050.         return $this;
  1051.     }
  1052.     public function getTitle(): ?string
  1053.     {
  1054.         return $this->title;
  1055.     }
  1056.     public function getTitleClean()
  1057.     {
  1058.         return preg_replace('/[^A-Za-z0-9 \-\.]/'' '$this->title); //remove special characters
  1059.     }
  1060.     public function setTitle(string $title null): self
  1061.     {
  1062.         $this->title $title preg_replace('~\x{00a0}~siu'' '$title) : "";
  1063.         return $this;
  1064.     }
  1065.     public function getSlug(): ?string
  1066.     {
  1067.         return $this->slug;
  1068.     }
  1069.     public function setSlug(string $slug null): self
  1070.     {
  1071.         $this->slug $slug $slug "";
  1072.         return $this;
  1073.     }
  1074.     public function getSearchable(): ?int
  1075.     {
  1076.         return $this->searchable;
  1077.     }
  1078.     public function setSearchable(int $searchable): self
  1079.     {
  1080.         $this->searchable $searchable;
  1081.         return $this;
  1082.     }
  1083.     
  1084.     public function getExcludeFromList(): ?int
  1085.     {
  1086.         return $this->exclude_from_list;
  1087.     }
  1088.     public function setExcludeFromList(int $exclude_from_list): self
  1089.     {
  1090.         $this->exclude_from_list $exclude_from_list;
  1091.         return $this;
  1092.     }
  1093.     public function getPermission(): ?int
  1094.     {
  1095.         return $this->permission;
  1096.     }
  1097.     public function setPermission(int $permission): self
  1098.     {
  1099.         $this->permission $permission;
  1100.         return $this;
  1101.     }
  1102.     public function getStatus(): ?int
  1103.     {
  1104.         return $this->status;
  1105.     }
  1106.  
  1107.     public function getStatusText ()
  1108.     {
  1109.         switch ($this->status) {
  1110.             
  1111.             case self::STATUS_SCHEDULED:
  1112.                 return "Scheduled";
  1113.                 
  1114.             case self::STATUS_ACTIVE:
  1115.                 return "Active";
  1116.                 
  1117.             case self::STATUS_INACTIVE:
  1118.                 return "Draft";
  1119.                 
  1120.             case self::STATUS_IN_REVIEW:
  1121.                 return "In Review";
  1122.                 
  1123.             case self::STATUS_EXPIRED:
  1124.                 return "Expired";
  1125.                 
  1126.             case self::STATUS_TRASH:
  1127.                 return "Trash";
  1128.                 
  1129.             case self::STATUS_SPAM:
  1130.                 return "Spam";
  1131.         }
  1132.         
  1133.         return "Inactive";
  1134.     }
  1135.     public function setStatus(int $status): self
  1136.     {
  1137.         $this->status $status;
  1138.         return $this;
  1139.     }
  1140.     /*
  1141.     public function getMembersOnly(): ?int
  1142.     {
  1143.         return $this->members_only;
  1144.     }
  1145.     
  1146.     public function setMembersOnly(int $members_only): self
  1147.     {
  1148.         $this->members_only = $members_only;
  1149.         
  1150.         return $this;
  1151.     }
  1152.     */
  1153.     public function getMembersOnly(): ?bool
  1154.     {
  1155.         return $this->members_only == 1;
  1156.     }
  1157.     
  1158.     public function setMembersOnly(bool $value): self
  1159.     {
  1160.         $this->members_only $value 0;
  1161.         return $this;
  1162.     }
  1163.     
  1164.     public function getIncludeAuthorByline(): ?bool
  1165.     {
  1166.         return $this->include_author_byline == 1;
  1167.     }
  1168.     
  1169.     public function setIncludeAuthorByline(bool $value): self
  1170.     {
  1171.         $this->include_author_byline $value 0;
  1172.         return $this;
  1173.     }
  1174.     public function getIncludeAuthorBio(): ?bool
  1175.     {
  1176.         return $this->include_author_bio == 1;
  1177.     }
  1178.     
  1179.     public function setIncludeAuthorBio(bool $value): self
  1180.     {
  1181.         $this->include_author_bio $value 0;
  1182.         return $this;
  1183.     }
  1184.     public function getIncludeCustomerCallToAction(): ?bool
  1185.     {
  1186.         return $this->include_customer_call_to_action == 1;
  1187.     }
  1188.     
  1189.     public function setIncludeCustomerCallToAction(bool $value): self
  1190.     {
  1191.         $this->include_customer_call_to_action $value 0;
  1192.         return $this;
  1193.     }
  1194.     public function getIncludeCustomerBio(): ?bool
  1195.     {
  1196.         return $this->include_customer_bio == 1;
  1197.     }
  1198.     
  1199.     public function setIncludeCustomerBio(bool $value): self
  1200.     {
  1201.         $this->include_customer_bio $value 0;
  1202.         return $this;
  1203.     }
  1204.     
  1205.     
  1206.     public function getTotalImpressions(): ?int
  1207.     {
  1208.         return $this->total_impressions;
  1209.     }
  1210.     
  1211.     public function setTotalImpressions(int $total_impressions): self
  1212.     {
  1213.         $this->total_impressions $total_impressions;
  1214.         
  1215.         return $this;
  1216.     }
  1217.     
  1218.     public function incrementTotalImpressions(): self
  1219.     {
  1220.         $this->total_impressions $this->total_impressions 1;
  1221.         return $this;
  1222.     }
  1223.     
  1224.     public function getTotalClicks(): ?int
  1225.     {
  1226.         return $this->total_clicks;
  1227.     }
  1228.     
  1229.     public function setTotalClicks(int $total_clicks): self
  1230.     {
  1231.         $this->total_clicks $total_clicks;
  1232.         
  1233.         return $this;
  1234.     }
  1235.     
  1236.     public function incrementTotalClicks(): self
  1237.     {
  1238.         $this->total_clicks $this->total_clicks 1;
  1239.         return $this;
  1240.     }
  1241.     
  1242.     public function getPublishedAt(): ?\DateTimeInterface
  1243.     {
  1244.         return $this->published_at;
  1245.     }
  1246.     public function setPublishedAt(\DateTimeInterface $scheduled_for): self
  1247.     {
  1248.         $this->published_at $scheduled_for;
  1249.         return $this;
  1250.     }
  1251.     public function getModifiedAt(): ?\DateTimeInterface
  1252.     {
  1253.         return $this->modified_at;
  1254.     }
  1255.     public function setModifiedAt(\DateTimeInterface $modified_at): self
  1256.     {
  1257.         $this->modified_at $modified_at;
  1258.         return $this;
  1259.     }
  1260.     public function getCreatedAt(): ?\DateTimeInterface
  1261.     {
  1262.         return $this->created_at;
  1263.     }
  1264.     public function setCreatedAt(\DateTimeInterface $created_at): self
  1265.     {
  1266.         $this->created_at $created_at;
  1267.         return $this;
  1268.     }
  1269.     public function getContentIntro(): ?string
  1270.     {
  1271.         return $this->content_intro;
  1272.     }
  1273.     public function setContentIntro(string $content_intro null): self
  1274.     {
  1275.         $this->content_intro $content_intro $content_intro "";
  1276.         return $this;
  1277.     }
  1278.     
  1279.     //Return the raw text of the content_intro if available, or else the start of content_full
  1280.     public function getIntroText($words 50): ?string
  1281.     {
  1282.         $content strip_tags($this->content_intro);
  1283.         $content preg_replace("~(?:\[/?)[^/\]]+/?\]~s"''$content); //strip short codes
  1284.         $content preg_replace('~\x{00a0}~siu'' '$content);
  1285.         $content str_replace('&nbsp;',' ',$content);
  1286.         $content trim($content);
  1287.         
  1288.         if (!$content) {
  1289.             $content strip_tags($this->content_full);
  1290.             $content preg_replace("~(?:\[/?)[^/\]]+/?\]~s"''$content);
  1291.             $content preg_replace('~\x{00a0}~siu'' '$content);
  1292.             $content str_replace('&nbsp;',' ',$content);
  1293.             $content trim($content);
  1294.         }
  1295.         
  1296.         $content explode(" "$content);
  1297.         
  1298.         if ($words count($content)) {
  1299.             $content array_slice($content0$words);
  1300.             $content[] = "...";
  1301.         }
  1302.         
  1303.         $content implode(" "$content);
  1304.         $content htmlspecialchars_decode($contentENT_QUOTES);
  1305.         $content html_entity_decode($content);
  1306.         return $content;
  1307.     }
  1308.     public function getContentFull(): ?string
  1309.     {
  1310.         return $this->content_full;
  1311.     }
  1312.     
  1313.     public function getContent_full (): ?string
  1314.     {
  1315.         return $this->content_full;
  1316.     }
  1317.     
  1318.     public function hasContent ()
  1319.     {
  1320.         $content str_replace(array(" ""&nbsp;"), ""$this->content_full);
  1321.         return $content !== "";
  1322.     }
  1323.     public function setContentFull(string $content_full null): self
  1324.     {
  1325.         /*
  1326.         //Can't do this, not safe
  1327.         if($content_full) {
  1328.             $content_full = htmlspecialchars_decode($content_full, ENT_QUOTES);
  1329.         }
  1330.         */
  1331.         $this->content_full $content_full $content_full "";
  1332.         return $this;
  1333.     }
  1334.     public function getAuthor(): ?User
  1335.     {
  1336.         return $this->author;
  1337.     }
  1338.     public function setAuthor(?User $author null): self
  1339.     {
  1340.         $this->author $author;
  1341.         return $this;
  1342.     }
  1343.     /**
  1344.      * @return Collection|ContentMeta[]
  1345.      */
  1346.     public function getContentmeta(): Collection
  1347.     {
  1348.         return $this->contentmeta;
  1349.     }
  1350.     
  1351.     /*
  1352.     public function getContentmetaArray()
  1353.     {
  1354.         $return = array();
  1355.         foreach( $this->contentmeta as meta) {
  1356.             $return["metakey"] = meta["metavalue"];
  1357.         }
  1358.         return $return;
  1359.     }
  1360.     */
  1361.     
  1362.     //only works with unique keys, otherwise returns the first
  1363.     public function getContentMetaByKey ($key "")
  1364.     {
  1365.         foreach ($this->contentmeta as $meta) {
  1366.             if ($meta->getMetakey() == $key) {
  1367.                 return $meta;
  1368.             }
  1369.         }
  1370.         return null;
  1371.     }
  1372.     
  1373.     
  1374.     public function getContentMetaValueByKey ($key "")
  1375.     {
  1376.         $meta $this->getContentMetaByKey($key);
  1377.         if ($meta) {
  1378.             return $meta->getMetavalue();
  1379.         }
  1380.         return "";
  1381.     }
  1382.     // sets the content meta with the provided certain key / value, or changes it if one with that key already exists
  1383.     public function setContentmetum($key ""$value "")
  1384.     {
  1385.         $meta $this->getContentMetaByKey($key);
  1386.         if ($meta) {
  1387.             $meta->setMetavalue($value);
  1388.         }
  1389.         else {
  1390.             $meta = new ContentMeta();
  1391.             $meta->setMetakey($key);
  1392.             $meta->setMetavalue($value);
  1393.             $this->addContentMetum($meta);
  1394.         }
  1395.         
  1396.     }
  1397.     
  1398.     // adds content meta with the provided key / value, even if one with that key already exists
  1399.     public function addContentMetumKV($key ""$value ""): self
  1400.     {
  1401.         $meta = new ContentMeta();
  1402.         $meta->setMetakey($key);
  1403.         $meta->setMetavalue($value);
  1404.         $this->addContentMetum($meta);
  1405.         
  1406.         return $this;
  1407.     }
  1408.     
  1409.     public function removeContentMetumKV($key ""$value ""): self
  1410.     {
  1411.         foreach ($this->contentmeta as $meta) {
  1412.             if ($meta->getMetakey() == $key && $meta->getMetavalue() == $value) {
  1413.                 $this->removeContentmetum($meta);
  1414.             }
  1415.         }
  1416.         
  1417.         return $this;
  1418.     }
  1419.     
  1420.     public function addContentMetum(ContentMeta $contentmetum): self
  1421.     {        
  1422.         if (!$this->contentmeta->contains($contentmetum)) {
  1423.             $this->contentmeta[] = $contentmetum;
  1424.             $contentmetum->setContent($this);
  1425.         }
  1426.         return $this;
  1427.     }
  1428.     
  1429.     public function removeContentmetum(ContentMeta $contentmetum): self
  1430.     {
  1431.         if ($this->contentmeta->contains($contentmetum)) {
  1432.             $this->contentmeta->removeElement($contentmetum);
  1433.             // set the owning side to null (unless already changed)
  1434.             if ($contentmetum->getContent() === $this) {
  1435.                 $contentmetum->setContent(null);
  1436.             }
  1437.         }
  1438.         return $this;
  1439.     }
  1440.     
  1441.     // value is not required
  1442.     public function countContentMetum($key ""$value ""): int
  1443.     {
  1444.         $count 0;
  1445.         foreach ($this->contentmeta as $meta) {
  1446.             if ($meta->getMetakey() == $key) {
  1447.                 if($value) {
  1448.                     if($meta->getMetavalue() == $value) {
  1449.                         $count++;
  1450.                     }
  1451.                 }
  1452.                 else {
  1453.                     $count++;
  1454.                 }
  1455.             }
  1456.         }
  1457.         return $count;
  1458.     }
  1459.     
  1460.     public function countLikes()
  1461.     {
  1462.         return $this->countContentMetum("_like_user_id");
  1463.     }
  1464.     
  1465.     public function __toString ()
  1466.     {
  1467.         return $this->title $this->title '';
  1468.     }
  1469.     public function getMetaDescription(): ?string
  1470.     {
  1471.         return $this->meta_description;
  1472.     }
  1473.     public function setMetaDescription(string $meta_description null): self
  1474.     {
  1475.         $this->meta_description $meta_description $meta_description "";
  1476.         return $this;
  1477.     }
  1478.     public function getMetaKeywords(): ?string
  1479.     {
  1480.         return $this->meta_keywords;
  1481.     }
  1482.     public function setMetaKeywords(string $meta_keywords null): self
  1483.     {
  1484.         $this->meta_keywords $meta_keywords $meta_keywords "";
  1485.         return $this;
  1486.     }
  1487.     
  1488.     public function toArray ()
  1489.     {
  1490.         $return = [];
  1491.         foreach ($this as $key => $value) {
  1492.             $return[$key] = $value;
  1493.         }
  1494.         return $return;
  1495.     }
  1496.     public function getCategory(): ?Category
  1497.     {
  1498.         return $this->category;
  1499.     }
  1500.     public function setCategory(?Category $category): self
  1501.     {
  1502.         //remove the previous primary category from the list of all categories
  1503.         //(is there a better way to do this?
  1504.         if($this->category) {
  1505.             $this->removeSecondaryCategory($this->category);
  1506.         }
  1507.         
  1508.         // also make sure category is set in the secondary categories too.
  1509.         if($category) {
  1510.             
  1511.             $this->addSecondaryCategory($category);
  1512.         }
  1513.         
  1514.         $this->category $category;
  1515.         return $this;
  1516.     }
  1517.     /**
  1518.      * @return Collection|Category[]
  1519.      */
  1520.     public function getSecondaryCategories(): Collection
  1521.     {
  1522.         return $this->secondary_categories;
  1523.     }
  1524.     public function addSecondaryCategory(Category $secondaryCategory): self
  1525.     {
  1526.         if (!$this->secondary_categories->contains($secondaryCategory)) {
  1527.             $this->secondary_categories[] = $secondaryCategory;
  1528.             $secondaryCategory->addSecondaryContent($this);
  1529.         }
  1530.         
  1531.         return $this;
  1532.     }
  1533.     
  1534.     public function resetSecondaryCategories(): self
  1535.     {
  1536.         $this->secondary_categories = new ArrayCollection();
  1537.         
  1538.         // retain the primary category if it exists
  1539.         if ($this->category) {
  1540.             $this->addSecondaryCategory($this->category);
  1541.         }
  1542.         return $this;
  1543.     }
  1544.     
  1545.     public function removeSecondaryCategory(Category $secondaryCategory): self
  1546.     {
  1547.         if ($this->secondary_categories->contains($secondaryCategory)) {
  1548.             $this->secondary_categories->removeElement($secondaryCategory);
  1549.             $secondaryCategory->removeSecondaryContent($this);
  1550.         }
  1551.         return $this;
  1552.     }
  1553.     
  1554.     public function getSecondaryCategoriesByTaxonomy ($taxonomy "")
  1555.     {
  1556.         $return = new ArrayCollection();
  1557.         
  1558.         $categories $this->secondary_categories;
  1559.         foreach ($categories as $category) {
  1560.             if ($category->getTaxonomy() == $taxonomy) {
  1561.                 $return[] = $category;
  1562.             }
  1563.         }
  1564.         
  1565.         return $return;
  1566.     }
  1567.     public function getPostCategories()
  1568.     {
  1569.         $return = [];
  1570.         $categories $this->secondary_categories;
  1571.         foreach ($categories as $category) {
  1572.             if ($category->getTaxonomy() == "category" || $category->getTaxonomy() == "aar_category") {
  1573.                 $return[] = $category->getTitle();
  1574.             }
  1575.         }
  1576.         
  1577.         return implode(", "$return);
  1578.     }
  1579.     
  1580.     /**
  1581.      * @return Collection|Children[]
  1582.      */
  1583.     public function getChildren(): Collection
  1584.     {
  1585.         return $this->children;
  1586.     }
  1587.     /*
  1588.     public function getPCDate()
  1589.     {
  1590.         $criteria = Criteria::create()
  1591.             ->where(Criteria::expr()->eq("status", "1"))
  1592.             ->orderBy(["published_at" => Criteria::DESC])
  1593.             ->setMaxResults(1)
  1594.         ;
  1595.         $lc = $this->getChildren()->matching($criteria);
  1596.         
  1597.         if($lc && $lc->getPublishedAt() > $this->getPublishedAt()) {
  1598.             $lc->getPublishedAt();
  1599.         }
  1600.         return $this->getPublishedAt();
  1601.     }*/
  1602.     
  1603.     
  1604.     /**
  1605.      * This works - but uses a very large amount of memory.
  1606.      * TODO - move into the controller
  1607.      * /
  1608.     public function countActiveGrandchildren() */
  1609.     
  1610.     public function getActiveChildren(): Collection
  1611.     {
  1612.         $criteria Criteria::create()
  1613.             ->where(Criteria::expr()->eq("status""1"))
  1614.             ->orderBy(["published_at" => Criteria::DESC])
  1615.         ;
  1616.         
  1617.         return $this->getChildren()->matching($criteria);
  1618.     }
  1619.     
  1620.     public function addChildren(Content $children): self
  1621.     {
  1622.         if (!$this->children->contains($children)) {
  1623.             $this->children[] = $children;
  1624.             $children->setPrnt($this);
  1625.         }
  1626.         return $this;
  1627.     }
  1628.     public function removeChildren(Content $children): self
  1629.     {
  1630.         if ($this->children->contains($children)) {
  1631.             $this->children->removeElement($children);
  1632.             // set the owning side to null (unless already changed)
  1633.             if ($children->getPrnt() === $this) {
  1634.                 $children->setPrnt(null);
  1635.             }
  1636.         }
  1637.         
  1638.         return $this;
  1639.     }
  1640.     
  1641.     /*
  1642.     public function getRelatedContents(): Collection
  1643.     {
  1644.         return $this->related_contents;
  1645.     }
  1646.     
  1647.     public function addRelatedContents(Content $content): self
  1648.     {
  1649.        // if (!$this->related_contents->contains($content)) {
  1650.             $this->related_contents[] = $content;
  1651.             //$children->setPrnt($this);
  1652.        // }
  1653.         return $this;
  1654.     }
  1655.     public function removeRelatedContents(Content $content): self
  1656.     {
  1657.         if ($this->related_contents->contains($content)) {
  1658.             $this->related_contents->removeElement($content);
  1659.             // set the owning side to null (unless already changed)
  1660.             //if ($children->getPrnt() === $this) {
  1661.                 //$children->setPrnt(null);
  1662.             //}
  1663.         }
  1664.         
  1665.         return $this;
  1666.     }
  1667.     */
  1668.     public function getPrimaryCustomer(): ?Customer
  1669.     {
  1670.         return $this->primaryCustomer;
  1671.     }
  1672.     public function getPrimaryCustomerTitleClean()
  1673.     {
  1674.         return $this->primaryCustomer $this->primaryCustomer->getTitleClean() : "";
  1675.     }
  1676.     public function setPrimaryCustomer(?Customer $customer): self
  1677.     {
  1678.         //remove the previous primary customer from the list of all customers
  1679.         //if($this->primaryCustomer) {
  1680.         //    $this->removeCustomer($this->primaryCustomer);
  1681.         //}
  1682.         
  1683.         // also make sure customer is set in the secondary customers too.
  1684.         if($customer) {
  1685.             $this->addCustomer($customer);
  1686.         }
  1687.         
  1688.         $this->primaryCustomer $customer;
  1689.         return $this;
  1690.     }
  1691.     
  1692.     /**
  1693.      * @return Collection|Customer[]
  1694.      */
  1695.     public function getCustomers(): Collection
  1696.     {
  1697.         return $this->customers;
  1698.     }
  1699.     public function getCustomerTitles()
  1700.     {
  1701.         $titles = [];
  1702.         foreach($this->customers as $customer) {
  1703.             $titles[] = $customer->getTitleClean();
  1704.         }
  1705.         return implode(", "$titles);
  1706.     }
  1707.     
  1708.     //don't think Sonata is using this
  1709.     public function addCustomers($customers): self
  1710.     {
  1711.         if(is_array($customers)) {
  1712.             foreach($customers as $customer) {
  1713.                 $this->addCustomer($customer);
  1714.             }
  1715.         }
  1716.         else {
  1717.             $this->customers->clear();
  1718.             $this->addCustomer($customers);
  1719.         }
  1720.         
  1721.         
  1722.         return $this;
  1723.     }
  1724.     public function addCustomer(Customer $customer): self
  1725.     {
  1726.         if (!$this->customers->contains($customer)) {
  1727.             $this->customers[] = $customer;
  1728.             $customer->addContent($this);
  1729.         }
  1730.         return $this;
  1731.     }
  1732.     public function removeCustomer(Customer $customer): self
  1733.     {
  1734.         if ($this->customers->contains($customer)) {
  1735.             $this->customers->removeElement($customer);
  1736.             $customer->removeContent($this);
  1737.         }
  1738.         return $this;
  1739.     }
  1740.     
  1741.     public function resetCustomers(): self
  1742.     {
  1743.         foreach($this->customers as $customer) {
  1744.             $this->removeCustomer($customer);
  1745.         }
  1746.         return $this;
  1747.     }
  1748.     
  1749.     public function setCustomers($customers) {
  1750.         $this->customers $customers;
  1751.         return $this;
  1752.     }
  1753.     
  1754.     // This is used for the forum replies column
  1755.     public function countUniqueChildrenAuthors(): int
  1756.     {
  1757.         //$authors[] = $this->getAuthor();
  1758.         $authors = array();
  1759.         foreach($this->getActiveChildren() as $child) {
  1760.             $authors[] = $child->getAuthor();
  1761.         }
  1762.         return count(array_unique($authors));
  1763.     }
  1764.  
  1765.  /**
  1766.   * @return Collection|Comment[]
  1767.   */
  1768.  public function getComments(): Collection
  1769.  {
  1770.      return $this->comments;
  1771.  }
  1772.  
  1773.  public function addComment(Comment $comment): self
  1774.  {
  1775.      if (!$this->comments->contains($comment)) {
  1776.          $this->comments[] = $comment;
  1777.          $comment->setContent($this);
  1778.      }
  1779.      
  1780.      return $this;
  1781.  }
  1782.  
  1783.  public function removeComment(Comment $comment): self
  1784.  {
  1785.      if ($this->comments->contains($comment)) {
  1786.          $this->comments->removeElement($comment);
  1787.          // set the owning side to null (unless already changed)
  1788.          if ($comment->getContent() === $this) {
  1789.              $comment->setContent(null);
  1790.          }
  1791.      }
  1792.      
  1793.      return $this;
  1794.  }
  1795.     
  1796.     public function getAge ()
  1797.     {
  1798.         // TODO - ...
  1799.         
  1800.         // EG has twig function - use that instead
  1801.         
  1802.     }
  1803.     
  1804.     public function getContentBuilder(): ?string
  1805.     {
  1806.         return $this->content_builder;
  1807.     }
  1808.     
  1809.     public function setContentBuilder(string $content_builder): self
  1810.     {
  1811.         $this->content_builder $content_builder;
  1812.      
  1813.         return $this;
  1814.     }
  1815.     /**
  1816.      * @return Collection|Order[]
  1817.      */
  1818.     public function getPurchaseItems(): Collection
  1819.     {
  1820.         return $this->purchase_items;
  1821.     }
  1822.     public function addPurchaseItem(PurchaseItem $order): self
  1823.     {
  1824.         if (!$this->purchase_items->contains($order)) {
  1825.             $this->purchase_items[] = $order;
  1826.             $order->setContent($this);
  1827.         }
  1828.         return $this;
  1829.     }
  1830.     public function removePurchaseItem(PurchaseItem $order): self
  1831.     {
  1832.         if ($this->purchase_items->contains($order)) {
  1833.             $this->purchase_items->removeElement($order);
  1834.             // set the owning side to null (unless already changed)
  1835.             if ($order->getContent() === $this) {
  1836.                 $order->setContent(null);
  1837.             }
  1838.         }
  1839.         return $this;
  1840.     }
  1841.     
  1842.     // - is this needed
  1843.     public function getCurrentPurchase (): ?Purchase
  1844.     {
  1845.         $purchase_item $this->purchase_items->first();
  1846.         if($purchase_item) {
  1847.             return $purchase_item->getPurchase();
  1848.         }
  1849.         else {
  1850.             return null;
  1851.         }
  1852.     }
  1853.     
  1854.     public function getCurrentPurchaseItem (): ?PurchaseItem
  1855.     {
  1856.         $purchase_item $this->purchase_items->first();
  1857.         if($purchase_item) {
  1858.             return $purchase_item;
  1859.         }
  1860.         else {
  1861.             return null;
  1862.         }
  1863.     }
  1864.     
  1865.     //returns the latest purchase item that HAS an associated Purchase object
  1866.     public function getCurrentActivePurchaseItem (): ?PurchaseItem
  1867.     {
  1868.         $purchase_items $this->purchase_items;
  1869.         foreach($purchase_items as $purchase_item) {
  1870.             $purchase $purchase_item->getPurchase();
  1871.             if($purchase) {
  1872.                 return $purchase_item;
  1873.             }
  1874.         }
  1875.         return null;
  1876.     }
  1877.     
  1878.     public function getURL ($site_id "")
  1879.     {
  1880.         switch ($this->type) {
  1881.             case self::STATIC_PAGE:
  1882.                 return "/{$this->slug}";
  1883.             case self::PAGE:
  1884.                 return "/{$this->slug}";
  1885.                 
  1886.             case self::POST:
  1887.                 return "/post/{$this->slug}";
  1888.                 
  1889.             case self::CLASSIFIED:
  1890.                 return "/listing/{$this->slug}";
  1891.                 
  1892.             case self::DIRECTORY:
  1893.                 return "/directory/{$this->slug}";
  1894.                 
  1895.             case self::GALLERY:
  1896.                 return "/gallery/{$this->slug}";
  1897.                 
  1898.             case self::LANDING_PAGE//TODO: Handle this better
  1899.                 if($site_id) {
  1900.                     return  '/' SiteConfig::CONFIGS[$site_id]['site_code'] . "/{$this->slug}";
  1901.                 }
  1902.                 else {
  1903.                     if(in_array(SELF::SITE_AAR$this->getSiteIds())) {
  1904.                         return "/aar/{$this->slug}";    
  1905.                     }
  1906.                     elseif(in_array(SELF::SITE_MCS$this->getSiteIds())) {
  1907.                         return "/mcs/{$this->slug}";    
  1908.                     }
  1909.                     elseif(in_array(SELF::SITE_CCS$this->getSiteIds())) {
  1910.                         return "/ccs/{$this->slug}";    
  1911.                     }
  1912.                     return "/rcs/{$this->slug}";
  1913.                 }
  1914.             
  1915.             case self::THANK_YOU_LANDING_PAGE:
  1916.                 return "/thank-you/{$this->slug}";
  1917.                 
  1918.             case self::FORUM:
  1919.                 return "/forum/{$this->slug}";
  1920.                 
  1921.             case self::FORUM_TOPIC:
  1922.                 return "/forum/topic/{$this->slug}";
  1923.                 
  1924.             case self::FORUM_REPLY:
  1925.                 if ($this->getPrnt()) {
  1926.                     return "/forum/topic/{$this->getPrnt()->getSlug()}";
  1927.                 }
  1928.                 return "/forum/topic/{$this->getSlug()}";
  1929.                 
  1930.             case self::PROMOS_REBATES:
  1931.                 return "/promos-rebates/{$this->slug}";
  1932.                 
  1933.             case self::THE_HUB:
  1934.                 return "/rlw/{$this->slug}";
  1935.                 
  1936.             case self::PODCAST:
  1937.                 return "/podcast/{$this->slug}";
  1938.                 
  1939.             case self::WEBINAR:
  1940.                 return "/webinar/{$this->slug}";
  1941.                 
  1942.             case self::EBOOK:
  1943.                 return "/ebooks/{$this->slug}";
  1944.                 
  1945.             case self::CONTEST_GAMES:
  1946.                 return "/contests-and-games/{$this->slug}";
  1947.                 
  1948.             case self::EVENT:
  1949.                 return "/event/{$this->slug}";
  1950.                 
  1951.             case self::AWARD:
  1952.                 return "/award/{$this->slug}";
  1953.                 
  1954.             case self::VIDEO:
  1955.                 return "/video/{$this->slug}";
  1956.                 
  1957.             case self::R_CLUB_PERK:
  1958.                 return "/r-club-perk/{$this->slug}";
  1959.                 
  1960.             case self::SCHOLARSHIP:
  1961.                 return "/scholarship/{$this->slug}";
  1962.             
  1963.         }
  1964.         
  1965.         return "#";
  1966.     }
  1967.     
  1968.     public function getFullURL($site_id_preferred "") {
  1969.         $site_ids $this->getSiteIds();
  1970.         
  1971.         if(in_array($site_id_preferred$site_ids)) {
  1972.             return "https://www." SiteConfig::CONFIGS[$site_id_preferred]['base_url'] . $this->getURL($site_id_preferred);
  1973.         }
  1974.         foreach($site_ids as $site_id) {
  1975.             return "https://www." SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
  1976.         }
  1977.         
  1978.         return "";
  1979.     }
  1980.     public function getFullURLs($site_id "") {
  1981.         $site_ids $site_id ? [$site_id] : $this->getSiteIds();
  1982.         
  1983.         $urls = [];
  1984.         foreach($site_ids as $site_id) {
  1985.             $urls[] =  "https://www." SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
  1986.         }
  1987.         
  1988.         return implode(", "$urls);
  1989.     }
  1990.     
  1991.     //Used for getting links from content admin pages
  1992.     public function getFullURLTags() {
  1993.         $site_ids $this->getSiteIds();
  1994.         $return "";
  1995.         foreach($site_ids as $site_id) {
  1996.             $url $this->getFullURL($site_id);
  1997.             $return .= "<a href='{$url}' target='blank'>{$url}</a><br>";
  1998.         }
  1999.         return $return;
  2000.     }
  2001.     
  2002.     public function getAbsoluteURL() {
  2003.         return $this->getFullURL();
  2004.     }
  2005.     
  2006.     public function getFullDevURL($site_id "") {
  2007.         $site_ids $site_id ? [$site_id] : $this->getSiteIds();
  2008.         
  2009.         foreach($site_ids as $site_id) {
  2010.             if($site_id == SELF::SITE_AAR) {
  2011.                 return "https://dev." SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
  2012.             }
  2013.             return "https://staging." SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
  2014.         }
  2015.         
  2016.         return "";
  2017.     }
  2018.     
  2019.     //Used for getting links from content admin pages
  2020.     public function getFullDevURLTags() {
  2021.         $site_ids $this->getSiteIds();
  2022.         $return "";
  2023.         foreach($site_ids as $site_id) {
  2024.             $url $this->getFullDevURL($site_id);
  2025.             $return .= "<a href='{$url}' target='blank'>{$url}</a><br>";
  2026.         }
  2027.         return $return;
  2028.     }
  2029.     
  2030.     public function getAdminEditURL() {
  2031.         
  2032.         $type_slug "content";
  2033.         
  2034.         switch ($this->type) {
  2035.             case self::STATIC_PAGE:
  2036.                 $type_slug "staticpage";
  2037.                 break;
  2038.             case self::PAGE:
  2039.                 $type_slug "page";
  2040.                 break;
  2041.             case self::POST:
  2042.                 $type_slug "post";
  2043.                 break;
  2044.             case self::CLASSIFIED:
  2045.                 $type_slug "classified";
  2046.                 break;
  2047.             case self::DIRECTORY:
  2048.                 $type_slug "directory";
  2049.                 break;
  2050.             case self::GALLERY:
  2051.                 $type_slug "gallery";
  2052.                 break;
  2053.             case self::LANDING_PAGE:
  2054.                 $type_slug "landingpage";
  2055.                 break;
  2056.             case self::FORUM:
  2057.                 $type_slug "forum";
  2058.                 break;
  2059.             case self::FORUM_TOPIC:
  2060.                 $type_slug "forumtopic";
  2061.                 break;
  2062.             case self::FORUM_REPLY:
  2063.                 $type_slug "forumreply";
  2064.                 break;
  2065.             case self::PROMOS_REBATES:
  2066.                 $type_slug "promosrebates";
  2067.                 break;
  2068.             case self::THE_HUB:
  2069.                 $type_slug "thehub";
  2070.                 break;
  2071.             case self::PODCAST:
  2072.                 $type_slug "podcast";
  2073.                 $category $this->getCategory();
  2074.                 if($category && $category->getSlug() == "partner-podcast") {
  2075.                     $type_slug "partnerpodcast";
  2076.                 }
  2077.                 break;
  2078.             case self::WEBINAR:
  2079.                 $type_slug "webinar";
  2080.                 $category $this->getCategory();
  2081.                 if($category && $category->getSlug() == "partner-webinar") {
  2082.                     $type_slug "partnerwebinar";
  2083.                 }
  2084.                 break;
  2085.             case self::EBOOK:
  2086.                 $type_slug "ebook";
  2087.                 break;
  2088.             case self::CONTEST_GAMES:
  2089.                 $type_slug "contestsgames";
  2090.                 break;
  2091.             case self::EVENT:
  2092.                 $type_slug "event";
  2093.                 break;
  2094.             case self::AWARD:
  2095.                 $type_slug "award";
  2096.                 break;
  2097.             case self::VIDEO:
  2098.                 $type_slug "video";
  2099.                 break;
  2100.             case self::R_CLUB_PERK:
  2101.                 $type_slug "rclubperk";
  2102.                 break;
  2103.             case self::SCHOLARSHIP:
  2104.                 $type_slug "scholarship";
  2105.                 break;
  2106.         }
  2107.         
  2108.         if($type_slug == "directory") {
  2109.             $customer $this->getDirectory();
  2110.             if($customer) {
  2111.                 return "/admin/app/customer/".$customer->getId()."/edit";
  2112.             }
  2113.         }
  2114.         $site_id $this->getSiteIds();
  2115.         $site_id $site_id[0];
  2116.         return "/admin/{$type_slug}/".$this->getId()."/edit?site=".$site_id//todo: if not current site, send to master admin view
  2117.         
  2118.     }
  2119.     
  2120.     //TODO: clean this up
  2121.     public static function getSitesForContentType($type) {
  2122.         
  2123.         switch ($type) {
  2124.             case self::PAGE:
  2125.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2126.             case self::POST:
  2127.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2128.             case self::CLASSIFIED:
  2129.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2130.             case self::DIRECTORY:
  2131.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2132.             case self::GALLERY:
  2133.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS]; //TODO: Partner gallery? Handle differently in individual admin pages?
  2134.             case self::LANDING_PAGE:
  2135.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2136.             case self::FORUM:
  2137.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2138.             case self::FORUM_TOPIC:
  2139.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2140.             case self::FORUM_REPLY:
  2141.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2142.             case self::PROMOS_REBATES:
  2143.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2144.             case self::THE_HUB:
  2145.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2146.             case self::PODCAST:
  2147.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2148.             case self::WEBINAR:
  2149.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2150.             case self::EBOOK:
  2151.                 return [self::SITE_RCSself::SITE_AARself::SITE_MCSself::SITE_CCS];
  2152.             case self::CONTEST_GAMES:
  2153.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2154.             case self::EVENT:
  2155.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2156.             case self::AWARD:
  2157.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2158.             case self::VIDEO:
  2159.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2160.             case self::R_CLUB_PERK:
  2161.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2162.             case self::SCHOLARSHIP:
  2163.                 return [self::SITE_RCSself::SITE_MCSself::SITE_CCS];
  2164.         }
  2165.         
  2166.         return [0];
  2167.         
  2168.     }
  2169.     
  2170.     public static function getSitesForContentTypeString($type) {
  2171.         return implode(","self::getSitesForContentType($type));
  2172.     }
  2173.     
  2174.     public function getShowTitle(): ?bool
  2175.     {
  2176.         return $this->showTitle == 1;
  2177.     }
  2178.     
  2179.     public function setShowTitle(bool $showTitle): self
  2180.     {
  2181.         $this->showTitle $showTitle 0;
  2182.         return $this;
  2183.     }
  2184.     public function getOldId(): ?int
  2185.     {
  2186.         return $this->old_id;
  2187.     }
  2188.     public function setOldId(int $old_id): self
  2189.     {
  2190.         $this->old_id $old_id;
  2191.         return $this;
  2192.     }
  2193.     /*
  2194.     public function getFeatured(): ?int
  2195.     {
  2196.         return $this->featured;
  2197.     }
  2198.     public function setFeatured(int $featured): self
  2199.     {
  2200.         $this->featured = $featured;
  2201.         return $this;
  2202.     }
  2203.     */
  2204.     
  2205.     public function getFeatured(): ?bool
  2206.     {
  2207.         return $this->featured == true;
  2208.     }
  2209.     
  2210.     public function setFeatured(bool $featured): self
  2211.     {
  2212.         $this->featured $featured 0;
  2213.         return $this;
  2214.     }
  2215.     
  2216.     public function getAnnouncement(): ?bool
  2217.     {
  2218.         return $this->announcement == true;
  2219.     }
  2220.     
  2221.     public function setAnnouncement(bool $announcement): self
  2222.     {
  2223.         $this->announcement $announcement 0;
  2224.         return $this;
  2225.     }
  2226.     public function getAnnouncementSites(): ?array
  2227.     {
  2228.         return json_decode($this->announcement_sites);
  2229.     }
  2230.     public function setAnnouncementSites(array $announcement_sites null): self
  2231.     {
  2232.         if (is_null($announcement_sites)) {
  2233.             $announcement_sites "";
  2234.         }
  2235.         
  2236.         $this->announcement_sites json_encode(array_values($announcement_sites));
  2237.         
  2238.         return $this;
  2239.     }
  2240.     
  2241.     public function getExpiresAt(): ?\DateTimeInterface
  2242.     {
  2243.         return $this->expires_at;
  2244.     }
  2245.     
  2246.     public function setExpiresAt(?\DateTimeInterface $expires_at): self
  2247.     {
  2248.         $this->expires_at $expires_at;
  2249.         
  2250.         return $this;
  2251.     }
  2252.     
  2253.     
  2254.     public function getMediaGroupContainers(): Collection
  2255.     {
  2256.         return $this->media_group_containers;
  2257.     }
  2258.     
  2259.     public function addMediaGroupContainer(MediaGroupContainer $media_group_container): self
  2260.     {
  2261.         if (!$this->media_group_containers->contains($media_group_container)) {
  2262.             $this->media_group_containers[] = $media_group_container;
  2263.             $media_group_container->setContent($this);
  2264.         }
  2265.         
  2266.         return $this;
  2267.     }
  2268.     
  2269.     public function setMediaGroupContainers (Collection $media_group_containers):self
  2270.     {
  2271.         $this->media_group_containers $media_group_containers;
  2272.         return $this;
  2273.     }
  2274.     
  2275.     public function removeMediaGroupContainer(MediaGroupContainer $media_group_container): self
  2276.     {
  2277.         if ($this->media_group_containers->contains($media_group_container)) {
  2278.             $this->media_group_containers->removeElement($media_group_container);
  2279.             // set the owning side to null (unless already changed)
  2280.             if ($media_group_container->getContent() === $this) {
  2281.                 $media_group_container->setContent(null);
  2282.             }
  2283.         }
  2284.         return $this;
  2285.     }
  2286.     public function getHootsuiteMessages(): Collection
  2287.     {
  2288.         return $this->hootsuite_messages;
  2289.     }
  2290.     public function addHootsuiteMessage(HootsuiteMessage $hootsuite_message): self
  2291.     {
  2292.         if (!$this->hootsuite_messages->contains($hootsuite_message)) {
  2293.             $this->hootsuite_messages[] = $hootsuite_message;
  2294.             $hootsuite_message->setContent($this);
  2295.         }
  2296.         return $this;
  2297.     }
  2298.     public function removeHootsuiteMessage(HootsuiteMessage $hootsuite_message): self
  2299.     {
  2300.         if ($this->hootsuite_messages->contains($hootsuite_message)) {
  2301.             $this->hootsuite_messages->removeElement($hootsuite_message);
  2302.             // set the owning side to null (unless already changed)
  2303.             if ($hootsuite_message->getContent() === $this) {
  2304.                 $hootsuite_message->setContent(null);
  2305.             }
  2306.         }
  2307.         return $this;
  2308.     }
  2309.     /*public function resetHootsuiteMessages(): self
  2310.     {
  2311.         $this->hootsuite_messages = new ArrayCollection();
  2312.         return $this;
  2313.     }*/
  2314.     
  2315.     //removes the mediagroupcontainer and deletes all related media groups / media. generally don't use this.
  2316.     /*
  2317.     public function deleteMediaGroupContainer(MediaGroupContainer $media_group_container): self
  2318.     {
  2319.         $containers = $this->getMediaGroupContainers();
  2320.         foreach($containers as $container) {
  2321.             $group = $container->getMediaGroup();
  2322.             $items = $group->getMediaGroupItems();
  2323.             foreach($items as $item) {
  2324.                 $group->removeMediaGroupItem($item);
  2325.             }
  2326.             //$container->removeMediaGroup($group);
  2327.             $this->removeMediaGroupContainer($container);
  2328.         }
  2329.         
  2330.         $this->removeMediaGroupContainer($media_group_container);
  2331.         return $this;
  2332.     }
  2333.     */
  2334.     
  2335.     
  2336.     public function getDirectory(): ?Customer
  2337.     {
  2338.         return $this->directory;
  2339.     }
  2340.     public function setDirectory(?Customer $directory): self
  2341.     {
  2342.         $this->directory $directory;
  2343.         // set (or unset) the owning side of the relation if necessary
  2344.         $newDirectory $directory === null null $this;
  2345.         if ($newDirectory !== $directory->getDirectoryContent()) {
  2346.             $directory->setDirectoryContent($newDirectory);
  2347.         }
  2348.         return $this;
  2349.     }
  2350.     
  2351.     
  2352.     /*
  2353.     public function getMediaGroupContainers(): Collection
  2354.     {
  2355.         return $this->media_group_containers;
  2356.     }
  2357.     public function addMediaGroupContainer(MediaGroupContainer $mediaGroupContainer): self
  2358.     {
  2359.         if (!$this->media_group_containers->contains($mediaGroupContainer)) {
  2360.             $this->media_group_containers[] = $mediaGroupContainer;
  2361.             $mediaGroupContainer->addContent($this);
  2362.         }
  2363.         return $this;
  2364.     }
  2365.     public function removeMediaGroupContainer(MediaGroupContainer $mediaGroupContainer): self
  2366.     {
  2367.         if ($this->media_group_containers->contains($mediaGroupContainer)) {
  2368.             $this->media_group_containers->removeElement($mediaGroupContainer);
  2369.             $mediaGroupContainer->removeContent($this);
  2370.         }
  2371.         return $this;
  2372.     }
  2373.     
  2374.     public function setMediaGroupContainers (Collection $mediaGroupContainers): self
  2375.     {
  2376.         $this->media_group_containers = $mediaGroupContainers;
  2377.         return $this;
  2378.     }
  2379.     
  2380.     */
  2381.     
  2382.     /**
  2383.      * @return Collection|Lead[]
  2384.      */
  2385.     public function getLeads(): Collection
  2386.     {
  2387.         return $this->leads;
  2388.     }
  2389.     public function addLead(Lead $lead): self
  2390.     {
  2391.         if (!$this->leads->contains($lead)) {
  2392.             $this->leads[] = $lead;
  2393.             $lead->setContent($this);
  2394.         }
  2395.         return $this;
  2396.     }
  2397.     public function removeLead(Lead $lead): self
  2398.     {
  2399.         if ($this->leads->contains($lead)) {
  2400.             $this->leads->removeElement($lead);
  2401.             // set the owning side to null (unless already changed)
  2402.             if ($lead->getContent() === $this) {
  2403.                 $lead->setContent(null);
  2404.             }
  2405.         }
  2406.         return $this;
  2407.     }
  2408.     public function getLatestLeads(): Collection
  2409.     {
  2410.         $criteria Criteria::create()
  2411.             ->orderBy(["created_at" => Criteria::DESC])
  2412.         ;
  2413.         return $this->getLeads()->matching($criteria);
  2414.     }
  2415.     
  2416.     /**
  2417.      * @return Collection|Traffic[]
  2418.      */
  2419.     public function getTraffic($year=0$month=0$day=0): Collection
  2420.     {
  2421.         return $this->traffic;
  2422.     }
  2423.     public function addTraffic(Traffic $traffic): self
  2424.     {
  2425.         if (!$this->traffic->contains($traffic)) {
  2426.             $this->traffic[] = $traffic;
  2427.             $traffic->setContent($this);
  2428.         }
  2429.         return $this;
  2430.     }
  2431.     public function removeTraffic(Traffic $traffic): self
  2432.     {
  2433.         if ($this->traffic->contains($traffic)) {
  2434.             $this->traffic->removeElement($traffic);
  2435.             // set the owning side to null (unless already changed)
  2436.             if ($traffic->getContent() === $this) {
  2437.                 $traffic->setContent(null);
  2438.             }
  2439.         }
  2440.         return $this;
  2441.     }
  2442.     
  2443.     public function getImpressions(): Collection
  2444.     {
  2445.         return $this->impressions;
  2446.     }
  2447.     
  2448.     public function getViews(): Collection
  2449.     {
  2450.         return $this->views;
  2451.     }
  2452.     
  2453.     public function getLinkClicks(): Collection
  2454.     {
  2455.         return $this->link_clicks;
  2456.     }
  2457.     
  2458.     public function getContentAnalyticsDaily(): Collection
  2459.     {
  2460.         return $this->content_analytics_daily;
  2461.     }
  2462.     
  2463.     public function getContentAnalyticsCorrectionDaily(): Collection
  2464.     {
  2465.         return $this->content_analytics_correction_daily;
  2466.     }
  2467.     
  2468.     /*
  2469.     //todo: https://stackoverflow.com/questions/32026743/symfony-2-php-comparing-dates-issues
  2470.     public function getImpressions($year=0, $month=0, $day=0)
  2471.     {
  2472.         $criteria = Criteria::create()
  2473.             ->where(Criteria::expr()->eq("type", "2"))
  2474.         ;
  2475.         
  2476.         return $this->getTraffic()->matching($criteria)->count();
  2477.         
  2478.         //Every time content is passed to render it is now added to an impression, so there's no need to add clicks.
  2479.         //return $this->getTraffic()->matching($criteria)->count() + $this->getClicks();
  2480.     }
  2481.     */
  2482.     
  2483.     public function getClicks($year=0$month=0$day=0)
  2484.     {
  2485.         $criteria Criteria::create()
  2486.             ->where(Criteria::expr()->eq("type""1"))
  2487.         ;
  2488.         
  2489.         return $this->getTraffic()->matching($criteria)->count();
  2490.     }
  2491.     
  2492.     
  2493.     
  2494.     public function getMediaGroups(): Collection
  2495.     {
  2496.         return $this->media_groups;
  2497.     }
  2498.     public function addMediaGroup(MediaGroup $mediaGroup): self
  2499.     {
  2500.         if (!$this->media_groups->contains($mediaGroup)) {
  2501.             
  2502.             //temp
  2503.             $mgContainer = new MediaGroupContainer();
  2504.             $mgContainer->setContent($this);
  2505.             $mgContainer->setMediaGroup($mediaGroup);
  2506.             $this->addMediaGroupContainer($mgContainer);
  2507.             
  2508.             $this->media_groups[] = $mediaGroup;
  2509.             $mediaGroup->addContent($this);
  2510.         }
  2511.         return $this;
  2512.     }
  2513.     public function removeMediaGroup(MediaGroup $mediaGroup): self
  2514.     {
  2515.         if ($this->media_groups->contains($mediaGroup)) {
  2516.             $this->media_groups->removeElement($mediaGroup);
  2517.             $mediaGroup->removeContent($this);
  2518.         }
  2519.         return $this;
  2520.     }
  2521.     
  2522.     public function setMediaGroups (Collection $mediaGroups): self
  2523.     {
  2524.         $this->media_groups $mediaGroups;
  2525.         return $this;
  2526.     }
  2527.     
  2528.     /*
  2529.     public function getImpressions(): ?int
  2530.     {
  2531.         return $this->impressions;
  2532.     }
  2533.     public function setImpressions(int $impressions): self
  2534.     {
  2535.         $this->impressions = $impressions;
  2536.         return $this;
  2537.     }
  2538.     */
  2539.     public function getHootsuiteSocialProfiles(): Collection
  2540.     {
  2541.         return $this->hootsuite_social_profiles;
  2542.     }
  2543.     public function addHootsuiteSocialProfile(HootsuiteSocialProfile $hootsuite_social_profile): self
  2544.     {
  2545.         if (!$this->hootsuite_social_profiles->contains($hootsuite_social_profile)) {
  2546.             $this->hootsuite_social_profiles[] = $hootsuite_social_profile;
  2547.             $hootsuite_social_profile->addContent($this);
  2548.         }
  2549.         
  2550.         return $this;
  2551.     }
  2552.     
  2553.     public function resetHootsuiteSocialProfiles(): self
  2554.     {
  2555.         $this->hootsuite_social_profiles = new ArrayCollection();
  2556.         return $this;
  2557.     }
  2558.     
  2559.     public function removeHootsuiteSocialProfile(HootsuiteSocialProfile $hootsuite_social_profile): self
  2560.     {
  2561.         if ($this->hootsuite_social_profiles->contains($hootsuite_social_profile)) {
  2562.             $this->hootsuite_social_profiles->removeElement($hootsuite_social_profile);
  2563.             $hootsuite_social_profile->removeContent($this);
  2564.         }
  2565.         return $this;
  2566.     }
  2567.     public function getHootsuiteContent(): ?string
  2568.     {
  2569.         return $this->hootsuite_content;
  2570.     }
  2571.     public function setHootsuiteContent(string $hootsuite_content null): self
  2572.     {
  2573.         $this->hootsuite_content $hootsuite_content $hootsuite_content "";
  2574.         return $this;
  2575.     }
  2576.     public function getHootsuiteFacebookContent(): ?string
  2577.     {
  2578.         return $this->hootsuite_facebook_content;
  2579.     }
  2580.     public function setHootsuiteFacebookContent(string $hootsuite_facebook_content null): self
  2581.     {
  2582.         $this->hootsuite_facebook_content $hootsuite_facebook_content $hootsuite_facebook_content "";
  2583.         return $this;
  2584.     }
  2585.     public function getHootsuiteTwitterContent(): ?string
  2586.     {
  2587.         return $this->hootsuite_twitter_content;
  2588.     }
  2589.     public function setHootsuiteTwitterContent(string $hootsuite_twitter_content null): self
  2590.     {
  2591.         $this->hootsuite_twitter_content $hootsuite_twitter_content $hootsuite_twitter_content "";
  2592.         return $this;
  2593.     }
  2594.     public function getHootsuiteLinkedinContent(): ?string
  2595.     {
  2596.         return $this->hootsuite_linkedin_content;
  2597.     }
  2598.     public function setHootsuiteLinkedinContent(string $hootsuite_linkedin_content null): self
  2599.     {
  2600.         $this->hootsuite_linkedin_content $hootsuite_linkedin_content $hootsuite_linkedin_content "";
  2601.         return $this;
  2602.     }
  2603.     public function getHootsuiteToPublish(): ?bool
  2604.     {
  2605.         return $this->hootsuite_to_publish == 1;
  2606.     }
  2607.     
  2608.     public function setHootsuiteToPublish(bool $value): self
  2609.     {
  2610.         $this->hootsuite_to_publish $value 0;
  2611.         return $this;
  2612.     }
  2613.     public function getHootsuiteUsePostMedia(): ?bool
  2614.     {
  2615.         return $this->hootsuite_use_post_media == 1;
  2616.     }
  2617.     
  2618.     public function setHootsuiteUsePostMedia(bool $value): self
  2619.     {
  2620.         $this->hootsuite_use_post_media $value 0;
  2621.         return $this;
  2622.     }
  2623.     public function getHootsuiteUsePostPublishedAt(): ?bool
  2624.     {
  2625.         return $this->hootsuite_use_post_published_at == 1;
  2626.     }
  2627.     
  2628.     public function setHootsuiteUsePostPublishedAt(bool $value): self
  2629.     {
  2630.         $this->hootsuite_use_post_published_at $value 0;
  2631.         return $this;
  2632.     }
  2633.     public function getHootsuiteMedia (): ?Media
  2634.     {
  2635.         return $this->hootsuite_media;
  2636.     }
  2637.     
  2638.     public function setHootsuiteMedia (Media $hootsuite_media null): self
  2639.     {
  2640.         $this->hootsuite_media $hootsuite_media;
  2641.         return $this;
  2642.     }
  2643.     public function getHootsuiteImageURL ()
  2644.     {
  2645.         if($this->hootsuite_media) {
  2646.             return $this->hootsuite_media->getURL();
  2647.         }
  2648.         return "";
  2649.     }
  2650.     public function getHootsuitePublishedAt(): ?\DateTimeInterface
  2651.     {
  2652.         return $this->hootsuite_published_at;
  2653.     }
  2654.     public function setHootsuitePublishedAt(?\DateTimeInterface $hootsuite_published_at): self
  2655.     {
  2656.         $this->hootsuite_published_at $hootsuite_published_at;
  2657.         return $this;
  2658.     }
  2659.     
  2660.     
  2661.     // -=-=-=- Virtual Properties for EasyAdmin -=-=-=-
  2662.     
  2663.     public function getTrafficCount ()
  2664.     {
  2665.         return $this->id;
  2666.         
  2667.         /*
  2668.         $sql = implode(" ", array (
  2669.             "SELECT",
  2670.                 "COUNT(t.id)",
  2671.             "FROM",
  2672.                 "App\Entity\Traffic t",
  2673.             "WHERE",
  2674.                 "t.user_this_route = :slug",
  2675.         ));
  2676.         
  2677.         $query = $this->em
  2678.             ->createQuery($sql)
  2679.             ->setParameter("slug", $this->slug);
  2680.         
  2681.         $count = $query->getResult();
  2682.         $count = $count[0][1];
  2683.         
  2684.         return $count;
  2685.         */
  2686.     }
  2687.     
  2688.     public function getScriptTag()
  2689.     {
  2690.         return $this->getContentMetaValueByKey("_custom_script_tag");
  2691.     }
  2692.     
  2693.     public function setScriptTag($value ""): self
  2694.     {
  2695.         $this->setContentmetum("_custom_script_tag"$value);
  2696.         return $this;
  2697.     }
  2698.     public function getPopoutAd(): ?MediaGroupItem
  2699.     {
  2700.         return $this->popout_ad;
  2701.     }
  2702.     public function setPopoutAd(?MediaGroupItem $item): self
  2703.     {
  2704.         $this->popout_ad $item;
  2705.         return $this;
  2706.     }
  2707.     
  2708.     // -----DIRECTORIES-----
  2709.     public function getDisplayOnPartnersPage(): ?bool
  2710.     {
  2711.         $val $this->getContentMetaValueByKey("_display_on_partners_page");
  2712.         return $val == "yes";
  2713.     }
  2714.     
  2715.     public function setDisplayOnPartnersPage(bool $value): self
  2716.     {
  2717.         $this->setContentmetum("_display_on_partners_page"$value "yes" "no");
  2718.         return $this;
  2719.     }
  2720.     public function getDirectoryEmailRecipients()
  2721.     {
  2722.         return $this->getContentMetaValueByKey("_directory_email_recipients");
  2723.     }
  2724.     
  2725.     public function setDirectoryEmailRecipients($value ""): self
  2726.     {
  2727.         $this->setContentmetum("_directory_email_recipients"$value);
  2728.         return $this;
  2729.     }
  2730.     public function getDirectoryEmailRecipientsArray()
  2731.     {
  2732.         $recipients = [];
  2733.         $valid_recipients false;
  2734.         foreach(explode(','$this->getDirectoryEmailRecipients()) as $recipient) {
  2735.             if ($recipient && filter_var(trim($recipient), FILTER_VALIDATE_EMAIL)) {
  2736.                 $recipients[] = trim($recipient);
  2737.                 $valid_recipients true;
  2738.             }
  2739.         }
  2740.         return $recipients;
  2741.     }
  2742.     
  2743.     public function getDirectoryAccountManagers()
  2744.     {
  2745.         return $this->getContentMetaValueByKey("_directory_account_managers");
  2746.     }
  2747.     
  2748.     public function setDirectoryAccountManagers($value ""): self
  2749.     {
  2750.         $this->setContentmetum("_directory_account_managers"$value);
  2751.         return $this;
  2752.     }
  2753.     // -----END DIRECTORIES-----
  2754.     // -----PAGES-----
  2755.     public function getZoomMeetingId()
  2756.     {
  2757.         return $this->getContentMetaValueByKey("_zoom_meeting_id");
  2758.     }
  2759.     
  2760.     public function setZoomMeetingId($value ""): self
  2761.     {
  2762.         $this->setContentmetum("_zoom_meeting_id"$value);
  2763.         return $this;
  2764.     }
  2765.     
  2766.     public function getZoomDisplayMeeting(): ?bool
  2767.     {
  2768.         $val $this->getContentMetaValueByKey("_zoom_display_meeting");
  2769.         return $val == "yes";
  2770.     }
  2771.     
  2772.     public function setZoomDisplayMeeting(bool $value): self
  2773.     {
  2774.         $this->setContentmetum("_zoom_display_meeting"$value "yes" "no");
  2775.         return $this;
  2776.     }
  2777.     // -----END PAGES-----
  2778.     
  2779.     // -----POSTS-----
  2780.     public function getPostAnnouncementEndDate(): ?\DateTimeInterface
  2781.     {
  2782.         if($this->getContentMetaValueByKey("_PostAnnouncementEndDate")) {
  2783.             return new \DateTime($this->getContentMetaValueByKey("_PostAnnouncementEndDate"));
  2784.         }
  2785.         return null;
  2786.     }
  2787.     
  2788.     public function setPostAnnouncementEndDate(?\DateTimeInterface $value): self
  2789.     {
  2790.         if($value) {
  2791.             $this->setContentmetum("_PostAnnouncementEndDate"$value->format("Y-m-d H:i:s"));
  2792.         }
  2793.         else {
  2794.             $this->setContentmetum("_PostAnnouncementEndDate""");
  2795.         }
  2796.         return $this;
  2797.     }
  2798.     // -----END POSTS-----
  2799.     
  2800.     // -----CLASSIFIEDS-----
  2801.     public function getClassifiedLocation()
  2802.     {
  2803.         return $this->getContentMetaValueByKey("_job_location");
  2804.     }
  2805.     
  2806.     public function setClassifiedLocation($value ""): self
  2807.     {
  2808.         $this->setContentmetum("_job_location"$value);
  2809.         return $this;
  2810.     }
  2811.     
  2812.     public function getClassifiedCompanyName()
  2813.     {
  2814.         return $this->getContentMetaValueByKey("_company_name");
  2815.     }
  2816.     
  2817.     public function setClassifiedCompanyName($value ""): self
  2818.     {
  2819.         $this->setContentmetum("_company_name"$value);
  2820.         return $this;
  2821.     }
  2822.     
  2823.     public function getClassifiedCompanyPhone()
  2824.     {
  2825.         return $this->getContentMetaValueByKey("_company_phone");
  2826.     }
  2827.     
  2828.     public function setClassifiedCompanyPhone($value ""): self
  2829.     {
  2830.         $this->setContentmetum("_company_phone"$value);
  2831.         return $this;
  2832.     }
  2833.     
  2834.     public function getClassifiedWebsite()
  2835.     {
  2836.         return $this->getContentMetaValueByKey("_company_website");
  2837.     }
  2838.     
  2839.     public function setClassifiedWebsite($value ""): self
  2840.     {
  2841.         $this->setContentmetum("_company_website"$value);
  2842.         return $this;
  2843.     }
  2844.     
  2845.     public function getClassifiedContactName()
  2846.     {
  2847.         return $this->getContentMetaValueByKey("_company_contact");
  2848.     }
  2849.     
  2850.     public function setClassifiedContactName($value ""): self
  2851.     {
  2852.         $this->setContentmetum("_company_contact"$value);
  2853.         return $this;
  2854.     }
  2855.     
  2856.     public function getClassifiedContactEmail()
  2857.     {
  2858.         return $this->getContentMetaValueByKey("_application");
  2859.     }
  2860.     
  2861.     public function setClassifiedContactEmail($value ""): self
  2862.     {
  2863.         $this->setContentmetum("_application"$value);
  2864.         return $this;
  2865.     }
  2866.     
  2867.     public function getClassifiedFileTitle()
  2868.     {
  2869.         return $this->getContentMetaValueByKey("_file_title");
  2870.     }
  2871.     
  2872.     public function setClassifiedFileTitle($value ""): self
  2873.     {
  2874.         $this->setContentmetum("_file_title"$value);
  2875.         
  2876.         //If there is already a file
  2877.         $containers $this->getMediaGroupContainers();
  2878.         foreach($containers as $container) {
  2879.             $group $container->getMediaGroup();
  2880.             if($group->getTitle() == "Classified Listing Files") {
  2881.                 $items $group->getMediaGroupItems();
  2882.                 foreach($items as $item) {
  2883.                     $media $item->getMedia();
  2884.                     $media->setTitle($value);
  2885.                 }
  2886.             }
  2887.         }
  2888.         
  2889.         return $this;
  2890.     }
  2891.     
  2892.     public function getClassifiedFile()
  2893.     {
  2894.         return "";
  2895.     }
  2896.     
  2897.     public function getClassifiedFileURL()
  2898.     {
  2899.         $containers $this->getMediaGroupContainers();
  2900.         foreach($containers as $container) {
  2901.             $group $container->getMediaGroup();
  2902.             if($group->getTitle() == "Classified Listing Files") {
  2903.                 $items $group->getMediaGroupItems();
  2904.                 foreach($items as $item) {
  2905.                     $media $item->getMedia();
  2906.                     return $media->getURL();
  2907.                 }
  2908.             }
  2909.         }
  2910.         
  2911.         return "";
  2912.         
  2913.     }
  2914.     
  2915.     public function setClassifiedFile(HttpFile $data null): self
  2916.     {
  2917.         if($data) {
  2918.             // upload the image
  2919.             // - using a media group in case we need to store more files in the future.
  2920.             $media = new Media();
  2921.             $media->setTitle($this->getClassifiedFileTitle() ? $this->getClassifiedFileTitle() : "Classified File");
  2922.             $media->setData($data);
  2923.             $media->setDescription("Classified Listing File");
  2924.             //$media->setName("Classified File");
  2925.             
  2926.             $continue true;
  2927.             //$this->removeClassifiedFile();
  2928.             $containers $this->getMediaGroupContainers();
  2929.             foreach($containers as $container) {
  2930.                 $group $container->getMediaGroup();
  2931.                 if($group->getTitle() == "Classified Listing Files") {
  2932.                     $items $group->getMediaGroupItems();
  2933.                     foreach($items as $item) {
  2934.                         $group->removeMediaGroupItem($item);
  2935.                     }
  2936.                     $mediaGroupItem = new MediaGroupItem();
  2937.                     $mediaGroupItem->setTitle("Classified Listing File");
  2938.                     $mediaGroupItem->setDescription("Classified Listing File");
  2939.                     $mediaGroupItem->setMedia($media);
  2940.                     
  2941.                     $group->addMediaGroupItem($mediaGroupItem);
  2942.                     
  2943.                     $continue false;
  2944.                 }
  2945.             }
  2946.             
  2947.             if($continue) {
  2948.                 $mediaGroupItem = new MediaGroupItem();
  2949.                 $mediaGroupItem->setTitle("Classified Listing File");
  2950.                 $mediaGroupItem->setDescription("Classified Listing File");
  2951.                 $mediaGroupItem->setMedia($media);
  2952.                 
  2953.                 $mediaGroup = new MediaGroup();
  2954.                 $mediaGroup->setTitle("Classified Listing Files");
  2955.                 $mediaGroup->setDescription("Classified Listing Files");
  2956.                 $mediaGroup->addMediaGroupItem($mediaGroupItem);
  2957.                 
  2958.                 $mediaGroupContainer = new MediaGroupContainer();
  2959.                 $mediaGroupContainer->setMediaGroup($mediaGroup);
  2960.                 $this->addMediaGroupContainer($mediaGroupContainer);
  2961.             }
  2962.         }
  2963.         return $this;
  2964.     }
  2965.     
  2966.     public function getClassifiedFileRemove(): ?bool
  2967.     {
  2968.         return false;
  2969.     }
  2970.     
  2971.     public function setClassifiedFileRemove(bool $var): self
  2972.     {
  2973.         return $this;
  2974.     }
  2975.     
  2976.     /*
  2977.     public function removeClassifiedFile(): self
  2978.     {
  2979.         $containers = $this->getMediaGroupContainers();
  2980.         foreach($containers as $container) {
  2981.             $this->deleteMediaGroupContainer($container);
  2982.         }
  2983.         
  2984.         return $this;
  2985.     }
  2986.     */
  2987.     
  2988.     /* Don't think this will work with easyadmin
  2989.     public function getClassifiedCategories(): Collection
  2990.     {
  2991.         $criteria = Criteria::create()
  2992.             ->where(Criteria::expr()->eq("status", "1"))
  2993.             ->andWhere(Criteria::expr()->eq("taxonomy", "job_listing_category"))
  2994.         ;
  2995.         
  2996.         return $this->getSecondaryCategories()->matching($criteria);
  2997.         
  2998.     }
  2999.     
  3000.     public function addClassifiedCategory(Category $category): self
  3001.     {
  3002.         $this->addSecondaryCategory($category);
  3003.         
  3004.         return $this;
  3005.     }*/
  3006.     // -----END CLASSIFIEDS-----
  3007.     
  3008.     // -----GALLERIES-----
  3009.     
  3010.     //$galleryMediaItems
  3011.     
  3012.     public function getGalleryMediaGroup(): ?MediaGroup
  3013.     {
  3014.         $mgContainers $this->getMediaGroupContainers();
  3015.         $mgContainer $mgContainers->first();
  3016.         $mediaGroup $mgContainer->getMediaGroup();
  3017.         
  3018.         return $mediaGroup;
  3019.     }
  3020.     
  3021.     public function getGalleryMediaItems(): Collection
  3022.     {
  3023.         $mediaGroup $this->getGalleryMediaGroup();
  3024.         $mgItems $mediaGroup->getMediaGroupItems();
  3025.             
  3026.         return $mgItems;
  3027.     }
  3028.     public function addGalleryMediaItem(MediaGroupItem $mediaGroupItem): self
  3029.     {
  3030.         $mediaGroup $this->getGalleryMediaGroup();
  3031.         $mediaGroup->addMediaGroupItem($mediaGroupItem);
  3032.         
  3033.         return $this;
  3034.     }
  3035.     
  3036.     public function setGalleryMediaItems (Collection $mediaGroupItems):self
  3037.     {
  3038.         $mediaGroup $this->getGalleryMediaGroup();
  3039.         $mediaGroup->setMediaGroupItems($mediaGroupItems)
  3040.         ;
  3041.         return $this;
  3042.     }
  3043.     public function removeGalleryMediaItems(MediaGroupItem $mediaGroupItem): self
  3044.     {
  3045.         $mediaGroup $this->getGalleryMediaGroup();
  3046.         $mediaGroup->removeMediaGroupItem($mediaGroupItem);
  3047.         return $this;
  3048.     }
  3049.     
  3050.     // -----END GALLERIES-----
  3051.     
  3052.     // -----EVENTS-----
  3053.     public function getEventStartDate(): ?\DateTimeInterface
  3054.     {
  3055.         if(!empty($this->getContentMetaValueByKey("_EventStartDate"))) {
  3056.             return new \DateTime($this->getContentMetaValueByKey("_EventStartDate"));
  3057.         }
  3058.         return null;
  3059.     }
  3060.     
  3061.     public function setEventStartDate(?\DateTimeInterface $value): self
  3062.     {
  3063.         if($value) {
  3064.             $this->setContentmetum("_EventStartDate"$value->format("Y-m-d H:i:s"));
  3065.         }
  3066.         else {
  3067.             $this->setContentmetum("_EventStartDate""");    
  3068.         }
  3069.         return $this;
  3070.     }
  3071.     
  3072.     public function getEventEndDate(): ?\DateTimeInterface
  3073.     {
  3074.         if(!empty($this->getContentMetaValueByKey("_EventEndDate"))) {
  3075.             return new \DateTime($this->getContentMetaValueByKey("_EventEndDate"));
  3076.         }
  3077.         return null;
  3078.     }
  3079.     
  3080.     public function setEventEndDate(?\DateTimeInterface $value): self
  3081.     {
  3082.         if($value) {
  3083.             $this->setContentmetum("_EventEndDate"$value->format("Y-m-d H:i:s"));
  3084.         }
  3085.         else {
  3086.             $this->setContentmetum("_EventEndDate""");    
  3087.         }
  3088.         return $this;
  3089.     }
  3090.     
  3091.     public function getEventAllDay(): ?bool
  3092.     {
  3093.         $val $this->getContentMetaValueByKey("_EventAllDay");
  3094.         return $val == "yes";
  3095.     }
  3096.     
  3097.     public function setEventAllDay(bool $value): self
  3098.     {
  3099.         $this->setContentmetum("_EventAllDay"$value "yes" "no");
  3100.         return $this;
  3101.     }
  3102.     
  3103.     public function getEventTimezone()
  3104.     {
  3105.         return $this->getContentMetaValueByKey("_EventTimezone");
  3106.     }
  3107.     
  3108.     public function setEventTimezone($value ""): self
  3109.     {
  3110.         $this->setContentmetum("_EventTimezone"$value);
  3111.         return $this;
  3112.     }
  3113.     
  3114.     
  3115.     
  3116.     public function getEventCost()
  3117.     {
  3118.         return $this->getContentMetaValueByKey("_EventCost");
  3119.     }
  3120.     
  3121.     public function setEventCost($value ""): self
  3122.     {
  3123.         $this->setContentmetum("_EventCost"$value);
  3124.         return $this;
  3125.     }
  3126.     
  3127.     public function getEventWebsite()
  3128.     {
  3129.         return $this->getContentMetaValueByKey("_EventURL");
  3130.     }
  3131.     
  3132.     public function setEventWebsite($value ""): self
  3133.     {
  3134.         $this->setContentmetum("_EventURL"$value);
  3135.         return $this;
  3136.     }
  3137.     
  3138.     
  3139.     // EVENT ORGANIZERS
  3140.     public function getEventOrganizerTitle()
  3141.     {
  3142.         return $this->getContentMetaValueByKey("_OrganizerTitle");
  3143.     }
  3144.     
  3145.     public function setEventOrganizerTitle($value ""): self
  3146.     {
  3147.         $this->setContentmetum("_OrganizerTitle"$value);
  3148.         return $this;
  3149.     }
  3150.     
  3151.     public function getEventOrganizerPhone()
  3152.     {
  3153.         return $this->getContentMetaValueByKey("_OrganizerPhone");
  3154.     }
  3155.     
  3156.     public function setEventOrganizerPhone($value ""): self
  3157.     {
  3158.         $this->setContentmetum("_OrganizerPhone"$value);
  3159.         return $this;
  3160.     }
  3161.     
  3162.     public function getEventOrganizerEmail()
  3163.     {
  3164.         return $this->getContentMetaValueByKey("_OrganizerEmail");
  3165.     }
  3166.     
  3167.     public function setEventOrganizerEmail($value ""): self
  3168.     {
  3169.         $this->setContentmetum("_OrganizerEmail"$value);
  3170.         return $this;
  3171.     }
  3172.     
  3173.     public function getEventOrganizerWebsite()
  3174.     {
  3175.         return $this->getContentMetaValueByKey("_OrganizerWebsite");
  3176.     }
  3177.     
  3178.     public function setEventOrganizerWebsite($value ""): self
  3179.     {
  3180.         $this->setContentmetum("_OrganizerWebsite"$value);
  3181.         return $this;
  3182.     }
  3183.     
  3184.     // EVENT VENUES
  3185.     
  3186.     public function getEventVenueTitle()
  3187.     {
  3188.         return $this->getContentMetaValueByKey("_VenueTitle");
  3189.     }
  3190.     
  3191.     public function setEventVenueTitle($value ""): self
  3192.     {
  3193.         $this->setContentmetum("_VenueTitle"$value);
  3194.         return $this;
  3195.     }
  3196.     
  3197.     public function getEventVenueAddress()
  3198.     {
  3199.         return $this->getContentMetaValueByKey("_VenueAddress");
  3200.     }
  3201.     
  3202.     public function setEventVenueAddress($value ""): self
  3203.     {
  3204.         $this->setContentmetum("_VenueAddress"$value);
  3205.         return $this;
  3206.     }
  3207.     
  3208.     public function getEventVenueCity()
  3209.     {
  3210.         return $this->getContentMetaValueByKey("_VenueCity");
  3211.     }
  3212.     
  3213.     public function setEventVenueCity($value ""): self
  3214.     {
  3215.         $this->setContentmetum("_VenueCity"$value);
  3216.         return $this;
  3217.     }
  3218.     
  3219.     public function getEventVenueState()
  3220.     {
  3221.         return $this->getContentMetaValueByKey("_VenueState");
  3222.     }
  3223.     
  3224.     public function setEventVenueState($value ""): self
  3225.     {
  3226.         $this->setContentmetum("_VenueState"$value);
  3227.         return $this;
  3228.     }
  3229.     
  3230.     public function getEventVenueZip()
  3231.     {
  3232.         return $this->getContentMetaValueByKey("_VenueZip");
  3233.     }
  3234.     
  3235.     public function setEventVenueZip($value ""): self
  3236.     {
  3237.         $this->setContentmetum("_VenueZip"$value);
  3238.         return $this;
  3239.     }
  3240.     
  3241.     public function getEventVenueCountry()
  3242.     {
  3243.         return $this->getContentMetaValueByKey("_VenueCountry");
  3244.     }
  3245.     
  3246.     public function setEventVenueCountry($value ""): self
  3247.     {
  3248.         $this->setContentmetum("_VenueCountry"$value);
  3249.         return $this;
  3250.     }
  3251.     
  3252.     public function getEventVenuePhone()
  3253.     {
  3254.         return $this->getContentMetaValueByKey("_VenuePhone");
  3255.     }
  3256.     
  3257.     public function setEventVenuePhone($value ""): self
  3258.     {
  3259.         $this->setContentmetum("_VenuePhone"$value);
  3260.         return $this;
  3261.     }
  3262.     
  3263.     public function getEventVenueURL()
  3264.     {
  3265.         return $this->getContentMetaValueByKey("_VenueURL");
  3266.     }
  3267.     
  3268.     public function setEventVenueURL($value ""): self
  3269.     {
  3270.         $this->setContentmetum("_VenueURL"$value);
  3271.         return $this;
  3272.     }
  3273.     
  3274.     //Used for non-Events (e.g. Webinars) so that they can be displayed as an Event
  3275.     public function getIsEvent(): ?bool
  3276.     {
  3277.         $val $this->getContentMetaValueByKey("_IsEvent");
  3278.         return $val == "yes";
  3279.     }
  3280.     public function setIsEvent(bool $value): self
  3281.     {
  3282.         $this->setContentmetum("_IsEvent"$value "yes" "no");
  3283.         return $this;
  3284.     }
  3285.     
  3286.     
  3287.     // -----END EVENTS-----
  3288.     
  3289.     // -----FORUMS-----
  3290.     
  3291.     public function getForumSponsoredURL()
  3292.     {
  3293.         return $this->getContentMetaValueByKey("frm_sponsored_url");
  3294.     }
  3295.     
  3296.     public function setForumSponsoredURL($value ""): self
  3297.     {
  3298.         $this->setContentmetum("frm_sponsored_url"$value);
  3299.         return $this;
  3300.     }
  3301.     
  3302.     // -----END FORUMS-----
  3303.     
  3304.     // -----LANDING PAGES-----
  3305.     public function getForm (): ?Form
  3306.     {
  3307.         return $this->form;
  3308.     }
  3309.     
  3310.     public function setForm (Form $form null): self
  3311.     {
  3312.         $this->form $form;
  3313.         
  3314.         return $this;
  3315.     }
  3316.     
  3317.     public function getLPContent()
  3318.     {
  3319.         return $this->getContentMetaValueByKey("mtm_content_modules_1_mtm_module_text_area_2");
  3320.     }
  3321.     
  3322.     public function setLPContent($value ""): self
  3323.     {
  3324.         $this->setContentmetum("mtm_content_modules_1_mtm_module_text_area_2"$value);
  3325.         return $this;
  3326.     }
  3327.     
  3328.     public function getLPHeader()
  3329.     {
  3330.         return $this->getContentMetaValueByKey("_lp_header");
  3331.     }
  3332.     
  3333.     public function setLPHeader($value ""): self
  3334.     {
  3335.         $this->setContentmetum("_lp_header"$value);
  3336.         return $this;
  3337.     }
  3338.     
  3339.     public function getLPFooter()
  3340.     {
  3341.         return $this->getContentMetaValueByKey("_lp_footer");
  3342.     }
  3343.     
  3344.     public function setLPFooter($value ""): self
  3345.     {
  3346.         $this->setContentmetum("_lp_footer"$value);
  3347.         return $this;
  3348.     }
  3349.     
  3350.     public function getLPLeft()
  3351.     {
  3352.         return $this->getContentMetaValueByKey("_lp_left");
  3353.     }
  3354.     
  3355.     public function setLPLeft($value ""): self
  3356.     {
  3357.         $this->setContentmetum("_lp_left"$value);
  3358.         return $this;
  3359.     }
  3360.     
  3361.     public function getLPRight()
  3362.     {
  3363.         return $this->getContentMetaValueByKey("_lp_right");
  3364.     }
  3365.     
  3366.     public function setLPRight($value ""): self
  3367.     {
  3368.         $this->setContentmetum("_lp_right"$value);
  3369.         return $this;
  3370.     }
  3371.     
  3372.     public function getLPThankYouContents()
  3373.     {
  3374.         return $this->getContentMetaValueByKey("_lp_thank_you_contents");
  3375.     }
  3376.     
  3377.     public function setLPThankYouContents($value ""): self
  3378.     {
  3379.         $this->setContentmetum("_lp_thank_you_contents"$value);
  3380.         return $this;
  3381.     }
  3382.     
  3383.     public function getLPRecipients()
  3384.     {
  3385.         return $this->getContentMetaValueByKey("lp_recipients");
  3386.     }
  3387.     
  3388.     public function setLPRecipients($value ""): self
  3389.     {
  3390.         $this->setContentmetum("lp_recipients"$value);
  3391.         return $this;
  3392.     }
  3393.     
  3394.     //I can't use LPThankYou because the server gives a 403 error when entering a URL...
  3395.     public function getLPThankyou()
  3396.     {
  3397.         return $this->getContentMetaValueByKey("lp_thankyou");
  3398.     }
  3399.     
  3400.     public function setLPThankyou($value ""): self
  3401.     {
  3402.         $this->setContentmetum("lp_thankyou"$value);
  3403.         return $this;
  3404.     }
  3405.     
  3406.     //Using LPPage instead for the thank you page URL
  3407.     public function getLPPage()
  3408.     {
  3409.         return $this->getContentMetaValueByKey("lp_thankyou");
  3410.     }
  3411.     
  3412.     public function setLPPage($value ""): self
  3413.     {
  3414.         $this->setContentmetum("lp_thankyou"$value);
  3415.         return $this;
  3416.     }
  3417.     
  3418.     public function getLPButtonText()
  3419.     {
  3420.         return $this->getContentMetaValueByKey("btn_text");
  3421.     }
  3422.     
  3423.     public function setLPButtonText($value ""): self
  3424.     {
  3425.         $this->setContentmetum("btn_text"$value);
  3426.         return $this;
  3427.     }
  3428.     
  3429.     public function getLPOptIn()
  3430.     {
  3431.         return $this->getContentMetaValueByKey("lp_opt_in");
  3432.     }
  3433.     
  3434.     public function setLPOptIn($value ""): self
  3435.     {
  3436.         $this->setContentmetum("lp_opt_in"$value);
  3437.         return $this;
  3438.     }
  3439.     
  3440.     public function isNewLandingPage(): ?bool
  3441.     {
  3442.         $val $this->getContentMetaValueByKey("_lp_new_site");
  3443.         return $val == "yes";
  3444.     }
  3445.     
  3446.     public function setNewLandingPage(bool $value): self
  3447.     {
  3448.         $this->setContentmetum("_lp_new_site"$value "yes" "no");
  3449.         return $this;
  3450.     }
  3451.     
  3452.     
  3453.     public function getLPBgColor()
  3454.     {
  3455.         return $this->getContentMetaValueByKey("rcs_body_background_color");
  3456.     }
  3457.     
  3458.     public function setLPBgColor($value ""): self
  3459.     {
  3460.         $this->setContentmetum("rcs_body_background_color"$value);
  3461.         return $this;
  3462.     }
  3463.     
  3464.     public function getLPButtonColor()
  3465.     {
  3466.         return $this->getContentMetaValueByKey("btn_color");
  3467.     }
  3468.     
  3469.     public function setLPButtonColor($value ""): self
  3470.     {
  3471.         $this->setContentmetum("btn_color"$value);
  3472.         return $this;
  3473.     }
  3474.     
  3475.     public function getLPHeaderColor()
  3476.     {
  3477.         return $this->getContentMetaValueByKey("_lp_header_color");
  3478.     }
  3479.     
  3480.     public function setLPHeaderColor($value ""): self
  3481.     {
  3482.         $this->setContentmetum("_lp_header_color"$value);
  3483.         return $this;
  3484.     }
  3485.     
  3486.     public function getLPFooterColor()
  3487.     {
  3488.         return $this->getContentMetaValueByKey("_lp_footer_color");
  3489.     }
  3490.     
  3491.     public function setLPFooterColor($value ""): self
  3492.     {
  3493.         $this->setContentmetum("_lp_footer_color"$value);
  3494.         return $this;
  3495.     }
  3496.     
  3497.     public function getLPThankColor()
  3498.     {
  3499.         return $this->getContentMetaValueByKey("_lp_thank_color");
  3500.     }
  3501.     
  3502.     public function setLPThankColor($value ""): self
  3503.     {
  3504.         $this->setContentmetum("_lp_thank_color"$value);
  3505.         return $this;
  3506.     }
  3507.     
  3508.     public function getLPLeftColor()
  3509.     {
  3510.         return $this->getContentMetaValueByKey("_lp_left_color");
  3511.     }
  3512.     
  3513.     public function setLPLeftColor($value ""): self
  3514.     {
  3515.         $this->setContentmetum("_lp_left_color"$value);
  3516.         return $this;
  3517.     }
  3518.     
  3519.     public function getLPRightColor()
  3520.     {
  3521.         return $this->getContentMetaValueByKey("_lp_right_color");
  3522.     }
  3523.     
  3524.     public function setLPRightColor($value ""): self
  3525.     {
  3526.         $this->setContentmetum("_lp_right_color"$value);
  3527.         return $this;
  3528.     }
  3529.     
  3530.     public function getLPFormFirstname(): ?bool
  3531.     {
  3532.         $val $this->getContentMetaValueByKey("_lp_form_firstname");
  3533.         return $val == "yes";
  3534.     }
  3535.     
  3536.     public function setLPFormFirstname(bool $value): self
  3537.     {
  3538.         $this->setContentmetum("_lp_form_firstname"$value "yes" "no");
  3539.         return $this;
  3540.     }
  3541.     
  3542.     public function getLPFormLastname(): ?bool
  3543.     {
  3544.         $val $this->getContentMetaValueByKey("_lp_form_lastname");
  3545.         return $val == "yes";
  3546.     }
  3547.     
  3548.     public function setLPFormLastname(bool $value): self
  3549.     {
  3550.         $this->setContentmetum("_lp_form_lastname"$value "yes" "no");
  3551.         return $this;
  3552.     }
  3553.     
  3554.     public function getLPFormCompany(): ?bool
  3555.     {
  3556.         $val $this->getContentMetaValueByKey("_lp_form_company");
  3557.         return $val == "yes";
  3558.     }
  3559.     
  3560.     public function setLPFormCompany(bool $value): self
  3561.     {
  3562.         $this->setContentmetum("_lp_form_company"$value "yes" "no");
  3563.         return $this;
  3564.     }
  3565.     
  3566.     public function getLPFormAddress1(): ?bool
  3567.     {
  3568.         $val $this->getContentMetaValueByKey("_lp_form_address1");
  3569.         return $val == "yes";
  3570.     }
  3571.     
  3572.     public function setLPFormAddress1(bool $value): self
  3573.     {
  3574.         $this->setContentmetum("_lp_form_address1"$value "yes" "no");
  3575.         return $this;
  3576.     }
  3577.     public function getLPFormAddress2(): ?bool
  3578.     {
  3579.         $val $this->getContentMetaValueByKey("_lp_form_address2");
  3580.         return $val == "yes";
  3581.     }
  3582.     
  3583.     public function setLPFormAddress2(bool $value): self
  3584.     {
  3585.         $this->setContentmetum("_lp_form_address2"$value "yes" "no");
  3586.         return $this;
  3587.     }
  3588.     
  3589.     public function getLPFormCity(): ?bool
  3590.     {
  3591.         $val $this->getContentMetaValueByKey("_lp_form_city");
  3592.         return $val == "yes";
  3593.     }
  3594.     
  3595.     public function setLPFormCity(bool $value): self
  3596.     {
  3597.         $this->setContentmetum("_lp_form_city"$value "yes" "no");
  3598.         return $this;
  3599.     }
  3600.     
  3601.     public function getLPFormState(): ?bool
  3602.     {
  3603.         $val $this->getContentMetaValueByKey("_lp_form_state");
  3604.         return $val == "yes";
  3605.     }
  3606.     
  3607.     public function setLPFormState(bool $value): self
  3608.     {
  3609.         $this->setContentmetum("_lp_form_state"$value "yes" "no");
  3610.         return $this;
  3611.     }
  3612.     
  3613.     public function getLPFormZip(): ?bool
  3614.     {
  3615.         $val $this->getContentMetaValueByKey("_lp_form_zip");
  3616.         return $val == "yes";
  3617.     }
  3618.     
  3619.     public function setLPFormZip(bool $value): self
  3620.     {
  3621.         $this->setContentmetum("_lp_form_zip"$value "yes" "no");
  3622.         return $this;
  3623.     }
  3624.     
  3625.     public function getLPFormPhone(): ?bool
  3626.     {
  3627.         $val $this->getContentMetaValueByKey("_lp_form_phone");
  3628.         return $val == "yes";
  3629.     }
  3630.     
  3631.     public function setLPFormPhone(bool $value): self
  3632.     {
  3633.         $this->setContentmetum("_lp_form_phone"$value "yes" "no");
  3634.         return $this;
  3635.     }
  3636.     
  3637.     public function getLPFormEmail(): ?bool
  3638.     {
  3639.         $val $this->getContentMetaValueByKey("_lp_form_email");
  3640.         return $val == "yes";
  3641.     }
  3642.     
  3643.     public function setLPFormEmail(bool $value): self
  3644.     {
  3645.         $this->setContentmetum("_lp_form_email"$value "yes" "no");
  3646.         return $this;
  3647.     }
  3648.     
  3649.     public function getLPFormContractorType(): ?bool
  3650.     {
  3651.         $val $this->getContentMetaValueByKey("_lp_form_contractor_type");
  3652.         return $val == "yes";
  3653.     }
  3654.     
  3655.     public function setLPFormContractorType(bool $value): self
  3656.     {
  3657.         $this->setContentmetum("_lp_form_contractor_type"$value "yes" "no");
  3658.         return $this;
  3659.     }
  3660.     
  3661.     public function getLPFormImage(): ?bool
  3662.     {
  3663.         $val $this->getContentMetaValueByKey("_lp_form_image");
  3664.         return $val == "yes";
  3665.     }
  3666.     
  3667.     public function setLPFormImage(bool $value): self
  3668.     {
  3669.         $this->setContentmetum("_lp_form_image"$value "yes" "no");
  3670.         return $this;
  3671.     }
  3672.     
  3673.     public function getLPFormCode()
  3674.     {
  3675.         return $this->getContentMetaValueByKey("_lp_form_shortcode");
  3676.     }
  3677.     
  3678.     public function setLPFormCode($value ""): self
  3679.     {
  3680.         $this->setContentmetum("_lp_form_shortcode"$value);
  3681.         return $this;
  3682.     }
  3683.     
  3684.     public function getLPEmailSend(): ?bool
  3685.     {
  3686.         $val $this->getContentMetaValueByKey("_lp_email_send");
  3687.         return $val == "yes";
  3688.     }
  3689.     
  3690.     public function setLPEmailSend(bool $value): self
  3691.     {
  3692.         $this->setContentmetum("_lp_email_send"$value "yes" "no");
  3693.         return $this;
  3694.     }
  3695.     
  3696.     public function getLPEmailContents()
  3697.     {
  3698.         return $this->getContentMetaValueByKey("_lp_email_contents");
  3699.     }
  3700.     
  3701.     public function setLPEmailContents($value ""): self
  3702.     {
  3703.         $this->setContentmetum("_lp_email_contents"$value);
  3704.         return $this;
  3705.     }
  3706.     
  3707.     //CSS properties are not applied to img tags in an email.
  3708.     //This fix will set the img tags' width and height attributes based on the width and height of the inline styles.
  3709.     //  (Should move this fix to the EmailHelper so that it applies to all emails. Starting with it here for testing purposes.)
  3710.     public function getLPEmailContentsImgFix()
  3711.     {
  3712.         $html $this->getContentMetaValueByKey("_lp_email_contents");
  3713.         
  3714.         $dom = new \DOMDocument;
  3715.         $dom->loadHTML($html);
  3716.         $imgs $dom->getElementsByTagName('img');
  3717.         foreach($imgs as $img) {
  3718.             
  3719.             $style $img->getAttribute('style');
  3720.             if($style) {
  3721.                 $style_attributes = array();
  3722.                 preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/"$style$matchesPREG_SET_ORDER);
  3723.                 foreach ($matches as $match) {
  3724.                   $style_attributes[$match[1]] = $match[2];
  3725.                 }
  3726.                 
  3727.                 if(isset($style_attributes["width"])) {
  3728.                     $tmp explode('px'$style_attributes["width"]);
  3729.                     $img->setAttribute("width"array_shift($tmp));
  3730.                 }
  3731.                 if(isset($style_attributes["height"])) {
  3732.                     $tmp explode('px'$style_attributes["height"]);
  3733.                     $img->setAttribute("height"array_shift($tmp));
  3734.                 }
  3735.                 
  3736.             }
  3737.         }
  3738.         $html $dom->saveHTML();
  3739.         
  3740.         return $html;
  3741.     }
  3742.     
  3743.     public function getLPEmailButtonText()
  3744.     {
  3745.         return $this->getContentMetaValueByKey("_lp_email_btn_text");
  3746.     }
  3747.     
  3748.     public function setLPEmailButtonText($value ""): self
  3749.     {
  3750.         $this->setContentmetum("_lp_email_btn_text"$value);
  3751.         return $this;
  3752.     }
  3753.     
  3754.     /*public function getLPEmailButtonColor()
  3755.     {
  3756.         return $this->getContentMetaValueByKey("_lp_email_btn_color");
  3757.     }
  3758.     
  3759.     public function setLPEmailButtonColor($value = ""): self
  3760.     {
  3761.         $this->setContentmetum("_lp_email_btn_color", $value);
  3762.         return $this;
  3763.     }*/
  3764.     
  3765.     // -----END LANDING PAGES-----
  3766.     
  3767.     // -----PODCASTS-----
  3768.     /*
  3769.     Made a script to move these all into content_full... will probably delete these
  3770.     public function getPodcastSubtitle()
  3771.     {
  3772.         return $this->getContentMetaValueByKey("sub_header");
  3773.     }
  3774.     
  3775.     public function setPodcastSubtitle($value = ""): self
  3776.     {
  3777.         $this->setContentmetum("sub_header", $value);
  3778.         return $this;
  3779.     }
  3780.     
  3781.     public function getPodcastInThisEpisode()
  3782.     {
  3783.         return $this->getContentMetaValueByKey("in_this_episode");
  3784.     }
  3785.     
  3786.     public function setPodcastInThisEpisode($value = ""): self
  3787.     {
  3788.         $this->setContentmetum("in_this_episode", $value);
  3789.         return $this;
  3790.     }
  3791.     
  3792.     public function getPodcastEmbed()
  3793.     {
  3794.         return $this->getContentMetaValueByKey("podcast_embed");
  3795.     }
  3796.     
  3797.     public function setPodcastEmbed($value = ""): self
  3798.     {
  3799.         $this->setContentmetum("podcast_embed", $value);
  3800.         return $this;
  3801.     }
  3802.     */
  3803.     
  3804.     // -----END PODCASTS-----
  3805.     
  3806.     
  3807.     // -----EBOOKS-----
  3808.     
  3809.     public function getEbookPinned(): ?bool
  3810.     {
  3811.         $val $this->getContentMetaValueByKey("_ebook_pinned");
  3812.         return $val == "yes";
  3813.     }
  3814.     
  3815.     public function setEbookPinned(bool $value): self
  3816.     {
  3817.         $this->setContentmetum("_ebook_pinned"$value "yes" "no");
  3818.         return $this;
  3819.     }
  3820.     
  3821.     // -----END EBOOKS-----
  3822.     
  3823. }