src/Entity/Customer.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Collections\Criteria;
  7. /**
  8.  * A customer can currently represent a directory listing, or a classified listing.
  9.  * 
  10.  * Todo: should probably rename entity to: "Company"
  11.  * 
  12.  * @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
  13.  */
  14. class Customer
  15. {
  16.     const TYPE_PRODUCTS_SERVICES    =  1024;
  17.     const TYPE_DISTRIBUTORS         =  2048;
  18.     const TYPE_CONSULTANTS          =  4096;
  19.     const TYPE_CONTRACTORS          =  8192;
  20.     const TYPE_ASSOCIATIONS         16384;
  21.     const TYPE_MANUFACTURERS_REP    32768;
  22.     const TYPE_RCS_PARTNERS         65536;
  23.     
  24.     const TYPE_PRODUCTS_SERVICES_STRING    "Products & Services";
  25.     const TYPE_DISTRIBUTORS_STRING         "Distributors";
  26.     const TYPE_CONSULTANTS_STRING          "Consultants";
  27.     const TYPE_CONTRACTORS_STRING          "Contractors";
  28.     const TYPE_ASSOCIATIONS_STRING         "Associations";
  29.     const TYPE_MANUFACTURERS_REP_STRING    "Manufacturers Reps";
  30.     const TYPE_RCS_PARTNERS_STRING         "RCS Partners";
  31.     
  32.     const LEVEL_PREMIUM        1000;
  33.     const LEVEL_BEST        2000;
  34.     const LEVEL_BETTER        3000;
  35.     const LEVEL_GOOD        4000;
  36.     const LEVEL_RCLUB        4001;
  37.     const LEVEL_PARTNER        5000;
  38.     const LEVEL_STANDARD    6000;
  39.     
  40.     const COUNTRIES = [
  41.         'USA' => "USA",
  42.         'Canada' => "Canada",
  43.     ];
  44.     
  45.     const STATES_PROVINCES = [
  46.         'Alabama'=>'Alabama',
  47.         'Alaska'=>'Alaska',
  48.         'Arizona'=>'Arizona',
  49.         'Arkansas'=>'Arkansas',
  50.         'California'=>'California',
  51.         'Colorado'=>'Colorado',
  52.         'Connecticut'=>'Connecticut',
  53.         'Delaware'=>'Delaware',
  54.         'District of Columbia'=>'District of Columbia',
  55.         'Florida'=>'Florida',
  56.         'Georgia'=>'Georgia',
  57.         'Hawaii'=>'Hawaii',
  58.         'Idaho'=>'Idaho',
  59.         'Illinois'=>'Illinois',
  60.         'Indiana'=>'Indiana',
  61.         'Iowa'=>'Iowa',
  62.         'Kansas'=>'Kansas',
  63.         'Kentucky'=>'Kentucky',
  64.         'Louisiana'=>'Louisiana',
  65.         'Maine'=>'Maine',
  66.         'Maryland'=>'Maryland',
  67.         'Massachusetts'=>'Massachusetts',
  68.         'Michigan'=>'Michigan',
  69.         'Minnesota'=>'Minnesota',
  70.         'Mississippi'=>'Mississippi',
  71.         'Missouri'=>'Missouri',
  72.         'Montana'=>'Montana',
  73.         'Nebraska'=>'Nebraska',
  74.         'Nevada'=>'Nevada',
  75.         'New Hampshire'=>'New Hampshire',
  76.         'New Jersey'=>'New Jersey',
  77.         'New Mexico'=>'New Mexico',
  78.         'New York'=>'New York',
  79.         'North Carolina'=>'North Carolina',
  80.         'North Dakota'=>'North Dakota',
  81.         'Ohio'=>'Ohio',
  82.         'Oklahoma'=>'Oklahoma',
  83.         'Oregon'=>'Oregon',
  84.         'Pennsylvania'=>'Pennsylvania',
  85.         'Rhode Island'=>'Rhode Island',
  86.         'South Carolina'=>'South Carolina',
  87.         'South Dakota'=>'South Dakota',
  88.         'Tennessee'=>'Tennessee',
  89.         'Texas'=>'Texas',
  90.         'Utah'=>'Utah',
  91.         'Vermont'=>'Vermont',
  92.         'Virginia'=>'Virginia',
  93.         'Washington'=>'Washington',
  94.         'West Virginia'=>'West Virginia',
  95.         'Wisconsin'=>'Wisconsin',
  96.         'Wyoming'=>'Wyoming',
  97.         
  98.         "Alberta" => "Alberta"
  99.         "British Columbia" => "British Columbia"
  100.         "Manitoba" => "Manitoba"
  101.         "New Brunswick" => "New Brunswick"
  102.         "Newfoundland and Labrador" => "Newfoundland and Labrador"
  103.         "Northwest Territories" => "Northwest Territories"
  104.         "Nova Scotia" => "Nova Scotia"
  105.         "Nunavut" => "Nunavut",
  106.         "Ontario" => "Ontario"
  107.         "Prince Edward Island" => "Prince Edward Island"
  108.         "Quebec" => "Quebec"
  109.         "Saskatchewan" => "Saskatchewan"
  110.         "Yukon Territory" => "Yukon Territory",
  111.     ];
  112.   
  113.   const SITE_RCS 1;
  114.   const SITE_AAR 2;
  115.   const SITE_MCS 3;
  116.   const SITE_CCS 4;
  117.     
  118.     /**
  119.      * @ORM\Id()
  120.      * @ORM\GeneratedValue()
  121.      * @ORM\Column(type="bigint")
  122.      */
  123.     private $id;
  124.     
  125.     /**
  126.      * @ORM\Version @ORM\Column(type="integer")
  127.      */
  128.     private $version;
  129.     /**
  130.      * @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="children", cascade={"persist"})
  131.      * @ORM\JoinColumn(nullable=true)
  132.      */
  133.     private $prnt;
  134.     /**
  135.      * @ORM\OneToMany(targetEntity="App\Entity\Customer", mappedBy="prnt")
  136.      * @ORM\OrderBy({"title" = "ASC"})
  137.      */
  138.     private $children;
  139.     /**
  140.      * @ORM\Column(type="string", length=255)
  141.      */
  142.     private $title;
  143.     /**
  144.      * @ORM\Column(type="text")
  145.      */
  146.     private $description;
  147.     /**
  148.      * @ORM\Column(type="text")
  149.      */
  150.     private $call_to_action;
  151.     /**
  152.      * @ORM\Column(type="text")
  153.      */
  154.     private $bio;
  155.     /**
  156.      * @ORM\Column(type="datetime")
  157.      */
  158.     private $modified_at;
  159.     /**
  160.      * @ORM\Column(type="datetime")
  161.      */
  162.     private $created_at;
  163.     /**
  164.      * @ORM\Column(type="integer")
  165.      */
  166.     private $status;
  167.     /**
  168.      * @ORM\OneToMany(targetEntity="App\Entity\CustomerPhone", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
  169.      */
  170.     private $phones;
  171.     
  172.     /**
  173.      * @ORM\OneToMany(targetEntity="App\Entity\CustomerWebsite", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
  174.      */
  175.     private $websites;
  176.     
  177.     /**
  178.      * @ORM\OneToMany(targetEntity="App\Entity\CustomerAddress", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
  179.      */
  180.     private $addresses;
  181.     /**
  182.      * @ORM\Column(type="string", length=255)
  183.      */
  184.     private $email;
  185.     /**
  186.      * @ORM\Column(type="string", length=255)
  187.      */
  188.     private $external_request_more;
  189.     /**
  190.      * @ORM\Column(type="string", length=255)
  191.      */
  192.     private $website;
  193.     /**
  194.      * @ORM\Column(type="string", length=255)
  195.      */
  196.     private $facebook;
  197.     /**
  198.      * @ORM\Column(type="string", length=255)
  199.      */
  200.     private $twitter;
  201.     /**
  202.      * @ORM\Column(type="string", length=255)
  203.      */
  204.     private $linkedin;
  205.     /**
  206.      * @ORM\Column(type="string", length=255)
  207.      */
  208.     private $instagram;
  209.     
  210.     /**
  211.      * @ORM\Column(type="string", length=255)
  212.      */
  213.     private $tiktok;
  214.     /**
  215.      * @ORM\Column(type="string", length=255)
  216.      */
  217.     private $youtube;
  218.     
  219.     /**
  220.      * @ORM\Column(type="string", length=255)
  221.      */
  222.     private $hash_tag;
  223.     
  224.     /**
  225.      * @ORM\Column(type="string", length=255)
  226.      */
  227.     private $location//country
  228.     
  229.     /**
  230.      * @ORM\Column(type="string", length=255)
  231.      */
  232.     private $state//state/province
  233.     /**
  234.      * @ORM\OneToOne(targetEntity="App\Entity\MediaGroup", inversedBy="customer_literature", cascade={"persist", "remove"})
  235.      */
  236.     private $literature;
  237.     /**
  238.      * JGF - media_group will work but should we update "content" to handle this?
  239.      * 
  240.      * @ORM\OneToOne(targetEntity="App\Entity\MediaGroup", inversedBy="customer_photo_gallery", cascade={"persist", "remove"})
  241.      */
  242.     private $photo_gallery;
  243.     /**
  244.      * JGF - media_group will work but should we update "content" to handle this? 
  245.      * 
  246.      * @ORM\OneToOne(targetEntity="App\Entity\MediaGroup", inversedBy="customer_video_gallery", cascade={"persist", "remove"})
  247.      */
  248.     private $video_gallery;
  249.     
  250.     /**
  251.      * @ORM\OneToOne(targetEntity="App\Entity\Media", cascade={"persist", "remove"})
  252.      */
  253.     private $logo;
  254.     
  255.     /**
  256.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  257.      * @ORM\JoinColumn(nullable=true)
  258.      */
  259.     private $media;
  260.     
  261.     /**
  262.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
  263.      * @ORM\JoinColumn(nullable=true)
  264.      */
  265.     private $dummy_media//In sonata admin, can't have multiple ModelListType fields of the same type... event if one is unmapped
  266.     //Delete this as soon as it's fixed, really don't want this here as it adds a field to the database
  267.     /**
  268.      * @ORM\OneToOne(targetEntity="App\Entity\Link", cascade={"persist", "remove"})
  269.      */
  270.     private $blog;
  271.     /**
  272.      * @ORM\OneToOne(targetEntity="App\Entity\Link", cascade={"persist", "remove"})
  273.      */
  274.     private $branch_locator;
  275.     /**
  276.      * @ORM\OneToOne(targetEntity="App\Entity\Menu", cascade={"persist", "remove"})
  277.      */
  278.     private $external_events;
  279.     /**
  280.      * @ORM\OneToOne(targetEntity="App\Entity\Menu", cascade={"persist", "remove"})
  281.      */
  282.     private $newsletters;
  283.     
  284.     /**
  285.      * @ORM\OneToOne(targetEntity="App\Entity\Menu", cascade={"persist", "remove"})
  286.      */
  287.     private $partners_reps;
  288.     /**
  289.      * @ORM\OneToOne(targetEntity="App\Entity\Menu", cascade={"persist", "remove"})
  290.      */
  291.     private $rep_lines;
  292.     /**
  293.      * @ORM\Column(type="text")
  294.      */
  295.     private $keywords;
  296.     
  297.     /**
  298.      * @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="companies")
  299.      */
  300.     private $members;
  301.     /**
  302.      * @ORM\Column(type="integer")
  303.      */
  304.     private $customer_level;
  305.     /**
  306.      * @ORM\Column(type="integer")
  307.      */
  308.     private $customer_type;
  309.     
  310.     /**
  311.      * @ORM\ManyToMany(targetEntity="App\Entity\Content", inversedBy="customers", cascade={"persist"})
  312.      */
  313.     private $contents;
  314.     /**
  315.      * @ORM\OneToMany(targetEntity="App\Entity\Content", mappedBy="primaryCustomer")
  316.      */
  317.     private $primaryContents;
  318.     
  319.     
  320.     //This is just to simplify the relationship between the customer and its directory type content object...
  321.     /**
  322.      * @ORM\OneToOne(targetEntity="App\Entity\Content", inversedBy="directory", cascade={"persist", "remove"})
  323.      */
  324.     private $directory_content;
  325.     
  326.     /**
  327.      * @ORM\ManyToMany(targetEntity="App\Entity\Category", inversedBy="customers")
  328.      */
  329.     private $categories;
  330.     
  331.     /**
  332.      * @ORM\ManyToMany(targetEntity="App\Entity\MediaGroupItem", inversedBy="customers", cascade={"persist"})
  333.      */
  334.     private $mediaGroupItems;
  335.     
  336.     /**
  337.      * @ORM\OneToMany(targetEntity="App\Entity\Link", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
  338.      * @ORM\OrderBy({"id" = "DESC"})
  339.      */
  340.     private $links;
  341.     
  342.     /**
  343.      * @ORM\ManyToMany(targetEntity="App\Entity\Product", inversedBy="customers", cascade={"persist"})
  344.      */
  345.     private $products;
  346.     
  347.     /**
  348.      * @ORM\OneToMany(targetEntity="App\Entity\CustomerMeta", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
  349.      */
  350.     private $customermeta;
  351.     
  352.     /**
  353.      * @ORM\ManyToMany(targetEntity="App\Entity\Poll", inversedBy="customers", cascade={"persist"})
  354.      */
  355.     private $polls;
  356.     
  357.     /**
  358.      * @ORM\ManyToMany(targetEntity="App\Entity\Quiz", mappedBy="customers", cascade={"persist"})
  359.      */
  360.     private $quizzes;
  361.     
  362.     /**
  363.      * @ORM\Column(type="string", length=24)
  364.      */
  365.     private $type_work;
  366.     
  367.     /**
  368.      * @ORM\ManyToMany(targetEntity="App\Entity\Site", inversedBy="customers")
  369.      */
  370.     private $site;
  371.     /**
  372.      * @ORM\OneToMany(targetEntity="App\Entity\CustomerSiteLevel", mappedBy="customer", orphanRemoval=true, cascade={"persist", "remove"})
  373.      */
  374.     private $levels;
  375.     
  376.     public function __construct()
  377.     {
  378.         $this->title "";
  379.         $this->description "";
  380.         $this->call_to_action "";
  381.         $this->bio "";
  382.         $this->status 1;
  383.         $this->customer_level 6000;
  384.         $this->email "";
  385.         $this->external_request_more "";
  386.         $this->website "";
  387.         $this->facebok "";
  388.         $this->twitter "";
  389.         $this->linkedin "";
  390.         $this->instagram "";
  391.         $this->tiktok "";
  392.         $this->youtube "";
  393.         $this->hash_tag "";
  394.         $this->location "";
  395.         $this->state "";
  396.         $this->keywords "";
  397.         $this->customer_type 0;
  398.         $this->type_work "";
  399.         
  400.         $this->phones = new ArrayCollection();
  401.         $this->websites = new ArrayCollection();
  402.         $this->addresses = new ArrayCollection();
  403.         
  404.         $this->contents = new ArrayCollection();
  405.         $this->polls = new ArrayCollection();
  406.         $this->quizzes = new ArrayCollection();
  407.         $this->mediaGroupItems = new ArrayCollection();
  408.         
  409.         $this->created_at = new \DateTime("now");
  410.         $this->modified_at = new \DateTime("now");
  411.         
  412.         $this->members = new ArrayCollection();
  413.         $this->categories = new ArrayCollection();
  414.         
  415.         $this->products = new ArrayCollection();
  416.         $this->contentmeta = new ArrayCollection();
  417.         $this->site = new ArrayCollection();
  418.         $this->children = new ArrayCollection();
  419.     }
  420.     public function getDummyMedia (): ?Media
  421.     {
  422.         return $this->dummy_media;
  423.     }
  424.     
  425.     public function setDummyMedia (Media $dummy_media null): self
  426.     {
  427.         $this->dummy_media $dummy_media;
  428.         
  429.         return $this;
  430.     }
  431.     
  432.     public function getId()
  433.     {
  434.         return $this->id;
  435.     }
  436.     
  437.     public function getVersion() {
  438.         return $this->version;
  439.     }
  440.     
  441.     public function getPrnt(): ?self
  442.     {
  443.         return $this->prnt;
  444.     }
  445.     public function setPrnt(self $parent null): self
  446.     {
  447.         $this->prnt $parent;
  448.         return $this;
  449.     }
  450.     /**
  451.      * @return Collection
  452.      */
  453.     public function getChildren(): Collection
  454.     {
  455.         return $this->children;
  456.     }
  457.     public function getActiveChildren(): Collection
  458.     {
  459.         
  460.         $childDirs = [];
  461.         foreach($this->getChildren() as $child) {
  462.             $childDir $child->getDirectoryContent();
  463.             if($childDir && $childDir->getStatus() == 1) {
  464.                 $childDirs[] = $childDir;
  465.             }
  466.         }
  467.         //$childDirsCollection = new ArrayCollection($childDirs);
  468.         return $childDirs();
  469.     }
  470.     
  471.     public function addChildren(Customer $children): self
  472.     {
  473.         if (!$this->children->contains($children)) {
  474.             $this->children[] = $children;
  475.             $children->setPrnt($this);
  476.         }
  477.         return $this;
  478.     }
  479.     public function removeChildren(Customer $children): self
  480.     {
  481.         if ($this->children->contains($children)) {
  482.             $this->children->removeElement($children);
  483.             // set the owning side to null (unless already changed)
  484.             if ($children->getPrnt() === $this) {
  485.                 $children->setPrnt(null);
  486.             }
  487.         }
  488.         
  489.         return $this;
  490.     }
  491.     public function getTitle(): ?string
  492.     {
  493.         return $this->title;
  494.     }
  495.     public function getTitleClean()
  496.     {
  497.         return preg_replace('/[^A-Za-z0-9 \-\.]/'' '$this->title); //remove special characters
  498.     }
  499.     public function setTitle(string $title null): self
  500.     {
  501.         if (is_null($title)) {
  502.             $title "";
  503.         }
  504.         
  505.         $this->title $title;
  506.         return $this;
  507.     }
  508.     public function getDescription(): ?string
  509.     {
  510.         return $this->description;
  511.     }
  512.     public function setDescription(string $description null): self
  513.     {
  514.         if (is_null($description)) {
  515.             $description "";
  516.         }
  517.         
  518.         $this->description $description;
  519.         return $this;
  520.     }
  521.     public function getCallToAction(): ?string
  522.     {
  523.         return $this->call_to_action;
  524.     }
  525.     public function setCallToAction(string $call_to_action null): self
  526.     {
  527.         if (is_null($call_to_action)) {
  528.             $call_to_action "";
  529.         }
  530.         
  531.         $this->call_to_action $call_to_action;
  532.         return $this;
  533.     }
  534.     public function getBio(): ?string
  535.     {
  536.         return $this->bio;
  537.     }
  538.     public function setBio(string $bio null): self
  539.     {
  540.         if (is_null($bio)) {
  541.             $bio "";
  542.         }
  543.         
  544.         $this->bio $bio;
  545.         return $this;
  546.     }
  547.     public function getModifiedAt(): ?\DateTimeInterface
  548.     {
  549.         return $this->modified_at;
  550.     }
  551.     public function setModifiedAt(\DateTimeInterface $modified_at): self
  552.     {
  553.         $this->modified_at $modified_at;
  554.         return $this;
  555.     }
  556.     public function getCreatedAt(): ?\DateTimeInterface
  557.     {
  558.         return $this->created_at;
  559.     }
  560.     public function setCreatedAt(\DateTimeInterface $created_at): self
  561.     {
  562.         $this->created_at $created_at;
  563.         return $this;
  564.     }
  565.     public function getStatus(): ?int
  566.     {
  567.         return $this->status;
  568.     }
  569.     public function setStatus(int $status): self
  570.     {
  571.         $this->status $status;
  572.         return $this;
  573.     }
  574.     /**
  575.      * @return Collection|CustomerPhone[]
  576.      */
  577.     public function getPhones(): Collection
  578.     {
  579.         return $this->phones;
  580.     }
  581.     public function addPhone(CustomerPhone $phone): self
  582.     {
  583.         if (!$this->phones->contains($phone)) {
  584.             $this->phones[] = $phone;
  585.             $phone->setCustomer($this);
  586.         }
  587.         return $this;
  588.     }
  589.     public function removePhone(CustomerPhone $phone): self
  590.     {
  591.         if ($this->phones->contains($phone)) {
  592.             $this->phones->removeElement($phone);
  593.             // set the owning side to null (unless already changed)
  594.             if ($phone->getCustomer() === $this) {
  595.                 $phone->setCustomer(null);
  596.             }
  597.         }
  598.         return $this;
  599.     }
  600.     
  601.     public function resetPhones(): self
  602.     {
  603.         foreach($this->phones as $phone) {
  604.             $this->removePhone($phone);
  605.         }
  606.         
  607.         return $this;
  608.     }
  609.     
  610.      /**
  611.      * @return Collection|CustomerWebsite[]
  612.      */
  613.     public function getWebsites(): Collection
  614.     {
  615.         return $this->websites;
  616.     }
  617.     public function addWebsite(CustomerWebsite $website): self
  618.     {
  619.         if (!$this->websites->contains($website)) {
  620.             $this->websites[] = $website;
  621.             $website->setCustomer($this);
  622.         }
  623.         return $this;
  624.     }
  625.     public function removeWebsite(CustomerWebsite $website): self
  626.     {
  627.         if ($this->websites->contains($website)) {
  628.             $this->websites->removeElement($website);
  629.             // set the owning side to null (unless already changed)
  630.             if ($website->getCustomer() === $this) {
  631.                 $website->setCustomer(null);
  632.             }
  633.         }
  634.         return $this;
  635.     }
  636.     
  637.     public function resetWebsites(): self
  638.     {
  639.         foreach($this->websites as $website) {
  640.             $this->removeWebsite($website);
  641.         }
  642.         
  643.         return $this;
  644.     }
  645.     /**
  646.      * @return Collection|CustomerAddress[]
  647.      */
  648.     public function getAddresses(): Collection
  649.     {
  650.         return $this->addresses;
  651.     }
  652.     public function addAddress(CustomerAddress $address): self
  653.     {
  654.         if (!$this->addresses->contains($address)) {
  655.             $this->addresses[] = $address;
  656.             $address->setCustomer($this);
  657.         }
  658.         return $this;
  659.     }
  660.     public function removeAddress(CustomerAddress $address): self
  661.     {
  662.         if ($this->addresses->contains($address)) {
  663.             $this->addresses->removeElement($address);
  664.             // set the owning side to null (unless already changed)
  665.             if ($address->getCustomer() === $this) {
  666.                 $address->setCustomer(null);
  667.             }
  668.         }
  669.         return $this;
  670.     }
  671.     
  672.     public function resetAddresses(): self
  673.     {
  674.         foreach($this->addresses as $address) {
  675.             $this->removeAddress($address);
  676.         }
  677.         
  678.         return $this;
  679.     }
  680.     
  681.     public function __toString ()
  682.     {
  683.         return $this->title;
  684.     }
  685.     public function getEmail(): ?string
  686.     {
  687.         return $this->email;
  688.     }
  689.     // This is for external Request More Link -- everything has to be named youtube becuase... again this server is shit. 
  690.     public function getYoutube3(): ?string
  691.     {
  692.         return $this->external_request_more;
  693.     }
  694.     // This is for external Request More Link -- everything has to be named youtube becuase... again this server is shit. 
  695.     public function setYoutube3(string $external_request_more null): self
  696.     {
  697.         if (is_null($external_request_more)) {
  698.             $external_request_more "";
  699.         }
  700.         
  701.         $this->external_request_more $external_request_more;
  702.         return $this;
  703.     }
  704.     public function setEmail(string $email null): self
  705.     {
  706.         if (is_null($email)) {
  707.             $email "";
  708.         }
  709.         
  710.         $this->email $email;
  711.         return $this;
  712.     }
  713.     public function getWebsite(): ?string
  714.     {
  715.         return $this->website;
  716.     }
  717.     public function setWebsite(string $website null): self
  718.     {
  719.         if (is_null($website)) {
  720.             $website "";
  721.         }
  722.         
  723.         $this->website $website;
  724.         return $this;
  725.     }
  726.     public function getFacebook(): ?string
  727.     {
  728.         return $this->facebook;
  729.     }
  730.     public function setFacebook(string $facebook null): self
  731.     {
  732.         if (is_null($facebook)) {
  733.             $facebook "";
  734.         }
  735.         
  736.         $this->facebook $facebook;
  737.         return $this;
  738.     }
  739.     public function getTwitter(): ?string
  740.     {
  741.         return $this->twitter;
  742.     }
  743.     public function setTwitter(string $twitter null): self
  744.     {
  745.         if (is_null($twitter)) {
  746.             $twitter "";
  747.         }
  748.         
  749.         $this->twitter $twitter;
  750.         return $this;
  751.     }
  752.     public function getLinkedin(): ?string
  753.     {
  754.         return $this->linkedin;
  755.     }
  756.     public function setLinkedin(string $linkedin null): self
  757.     {
  758.         if (is_null($linkedin)) {
  759.             $linkedin "";
  760.         }
  761.         
  762.         $this->linkedin $linkedin;
  763.         return $this;
  764.     }
  765.     public function getInstagram(): ?string
  766.     {
  767.         return $this->instagram;
  768.     }
  769.     public function setInstagram(string $instagram null): self
  770.     {
  771.         if (is_null($instagram)) {
  772.             $instagram "";
  773.         }
  774.         
  775.         $this->instagram $instagram;
  776.         return $this;
  777.     }
  778.     // This is for the TikTok URL -- the server is a shit
  779.     public function getYoutube2(): ?string
  780.     {
  781.         return $this->tiktok;
  782.     }
  783.     
  784.     public function getTiktok(): ?string
  785.     {
  786.         return $this->tiktok;
  787.     }
  788.     
  789.     // This is for the TikTok URL -- the server is a shit
  790.     public function setYoutube2(string $tiktok null): self
  791.     {
  792.         if (is_null($tiktok)) {
  793.             $tiktok "";
  794.         }
  795.         
  796.         $this->tiktok $tiktok;
  797.         return $this;
  798.     }
  799.     public function getYoutube(): ?string
  800.     {
  801.         return $this->youtube;
  802.     }
  803.     public function setYoutube(string $youtube null): self
  804.     {
  805.         if (is_null($youtube)) {
  806.             $youtube "";
  807.         }
  808.         
  809.         $this->youtube $youtube;
  810.         return $this;
  811.     }
  812.     
  813.     public function getHashTag(): ?string
  814.     {
  815.         return $this->hash_tag;
  816.     }
  817.     public function setHashTag(string $hash_tag null): self
  818.     {
  819.         if (is_null($hash_tag)) {
  820.             $hash_tag "";
  821.         
  822.         }
  823.         $this->hash_tag $hash_tag;
  824.         return $this;
  825.     }
  826.     
  827.     /*
  828.     public function getLocation(): ?string
  829.     {
  830.         return $this->location;
  831.     }
  832.     public function setLocation(string $location = null): self
  833.     {
  834.         if (is_null($location)) {
  835.             $location = "";
  836.         }
  837.         
  838.         $this->location = $location;
  839.         return $this;
  840.     }
  841.     */
  842.     
  843.     public function getLocation(): ?array
  844.     {
  845.         return json_decode($this->location);
  846.     }
  847.     public function setLocation(array $location null): self
  848.     {
  849.         if (is_null($location)) {
  850.             $location "";
  851.         }
  852.         
  853.         $this->location json_encode($location);
  854.         
  855.         return $this;
  856.     }
  857.     
  858.     public function getState(): ?array
  859.     {
  860.         return json_decode($this->state);
  861.     }
  862.     public function setState(array $state null): self
  863.     {
  864.         if (is_null($state)) {
  865.             $state "";
  866.         }
  867.         
  868.         $this->state json_encode($state);
  869.         
  870.         return $this;
  871.     }
  872.     
  873.     public function getLiterature(): ?MediaGroup
  874.     {
  875.         return $this->literature;
  876.     }
  877.     public function setLiterature(?MediaGroup $literature): self
  878.     {
  879.         $this->literature $literature;
  880.         return $this;
  881.     }
  882.     public function getPhotoGallery(): ?MediaGroup
  883.     {
  884.         return $this->photo_gallery;
  885.     }
  886.     public function setPhotoGallery(?MediaGroup $photo_gallery): self
  887.     {
  888.         $this->photo_gallery $photo_gallery;
  889.         return $this;
  890.     }
  891.     public function getFirstPartnerGalleryMediaGroup()
  892.     {
  893.         $criteria Criteria::create()
  894.             ->where(Criteria::expr()->eq("type"5))
  895.             ->andWhere(Criteria::expr()->eq("status""1"))
  896.             ->andWhere(Criteria::expr()->eq("status""1"))
  897.             
  898.             //->join('.category', 'cat')
  899.             //->andWhere($query->expr()->eq('cat.slug', ':catSlug'))
  900.             //->setParameter('catSlug', 'partner-galleries')
  901.             
  902.             ->orderBy(array("published_at" => Criteria::DESC));
  903.         
  904.         $galleries $this->contents->matching($criteria);
  905.         $partnerGallery null;
  906.         foreach($galleries as $gallery) {
  907.             $partnerGallery $gallery;
  908.             $category $gallery->getCategory();
  909.             if($category && $category->getSlug() == "partner-galleries") {
  910.                 $containers $partnerGallery->getMediaGroupContainers();
  911.                 foreach($containers as $container) {
  912.                     $group $container->getMediaGroup();
  913.                     if($group && !$group->getMediaGroupItems()->isEmpty()) {
  914.                         return $group;
  915.                     }
  916.                 }
  917.             }
  918.         }
  919.         
  920.         
  921.         return $this->getPhotoGallery();
  922.         
  923.     }
  924.     public function getVideoGallery(): ?MediaGroup
  925.     {
  926.         return $this->video_gallery;
  927.     }
  928.     public function setVideoGallery(?MediaGroup $video_gallery): self
  929.     {
  930.         $this->video_gallery $video_gallery;
  931.         return $this;
  932.     }
  933.     public function getLogo(): ?Media
  934.     {
  935.         return $this->logo;
  936.     }
  937.     
  938.     public function getMedia (): ?Media
  939.     {
  940.         return $this->media;
  941.     }
  942.     
  943.     public function setMedia (Media $media null): self
  944.     {
  945.         $this->media $media;
  946.         
  947.         return $this;
  948.     }
  949.     public function setLogo(?Media $logo): self
  950.     {
  951.         $this->logo $logo;
  952.         return $this;
  953.     }
  954.     
  955.     public function getDirectoryContent(): ?Content
  956.     {
  957.         return $this->directory_content;
  958.     }
  959.     public function setDirectoryContent(?Content $directory_content): self
  960.     {
  961.         $this->directory_content $directory_content;
  962.         $this->addContent($directory_content);
  963.         return $this;
  964.     }
  965.     public function getBlog(): ?Link
  966.     {
  967.         return $this->blog;
  968.     }
  969.     public function setBlog(?Link $blog): self
  970.     {
  971.         $this->blog $blog;
  972.         return $this;
  973.     }
  974.     public function getBranchLocator(): ?Link
  975.     {
  976.         return $this->branch_locator;
  977.     }
  978.     public function setBranchLocator(?Link $branch_locator): self
  979.     {
  980.         $this->branch_locator $branch_locator;
  981.         return $this;
  982.     }
  983.     public function getExternalEvents(): ?Menu
  984.     {
  985.         return $this->external_events;
  986.     }
  987.     public function setExternalEvents(?Menu $external_events): self
  988.     {
  989.         $this->external_events $external_events;
  990.         return $this;
  991.     }
  992.     
  993.     public function setExternalEvent($title=""$url=""):self
  994.     {
  995.         $menu = new Menu();
  996.         $item = new MenuItem();
  997.         $link = new Link();
  998.         
  999.         $link->setTitle($title);
  1000.         $link->setRefExternal($url);
  1001.         
  1002.         $item->setTitle($title);
  1003.         $item->setLink($link);
  1004.         
  1005.         $menu->addMenuItem($item);
  1006.         
  1007.         $this->setExternalEvents($menu);
  1008.         
  1009.         return $this;
  1010.     }
  1011.     public function getNewsletters(): ?Menu
  1012.     {
  1013.         return $this->newsletters;
  1014.     }
  1015.     public function setNewsletters(?Menu $newsletters): self
  1016.     {
  1017.         $this->newsletters $newsletters;
  1018.         return $this;
  1019.     }
  1020.     public function getPartnersReps(): ?Menu
  1021.     {
  1022.         return $this->partners_reps;
  1023.     }
  1024.     public function setPartnersReps(?Menu $partners_reps): self
  1025.     {
  1026.         $this->partners_reps $partners_reps;
  1027.         return $this;
  1028.     }
  1029.     public function getRepLines(): ?Menu
  1030.     {
  1031.         return $this->rep_lines;
  1032.     }
  1033.     public function setRepLines(?Menu $rep_lines): self
  1034.     {
  1035.         $this->rep_lines $rep_lines;
  1036.         return $this;
  1037.     }
  1038.     public function getKeywords(): ?string
  1039.     {
  1040.         return $this->keywords;
  1041.     }
  1042.     public function setKeywords(string $keywords null): self
  1043.     {
  1044.         if (is_null($keywords)) {
  1045.             $keywords "";
  1046.         }
  1047.         
  1048.         $this->keywords $keywords;
  1049.         return $this;
  1050.     }
  1051.     
  1052.     /**
  1053.      * @return Collection|User[]
  1054.      */
  1055.     public function getMembers(): Collection
  1056.     {
  1057.         return $this->members;
  1058.     }
  1059.     public function addMember(User $member): self
  1060.     {
  1061.         if (!$this->members->contains($member)) {
  1062.             $this->members[] = $member;
  1063.         }
  1064.         return $this;
  1065.     }
  1066.     public function removeMember(User $member): self
  1067.     {
  1068.         if ($this->members->contains($member)) {
  1069.             $this->members->removeElement($member);
  1070.         }
  1071.         return $this;
  1072.     }
  1073.     public function getCustomerLevel($site_id ""): ?int
  1074.     {
  1075.         if($site_id) {
  1076.             foreach($this->getLevels() as $level) {
  1077.                 if($level->getSiteId() == $site_id) {
  1078.                     return $level->getLevel();
  1079.                 }
  1080.             }
  1081.         }
  1082.         return $this->customer_level;
  1083.     }
  1084.     public function setCustomerLevel(int $customer_level): self
  1085.     {
  1086.         $this->customer_level $customer_level;
  1087.         return $this;
  1088.     }
  1089.     public function getCustomerType(): ?int
  1090.     {
  1091.         return $this->customer_type;
  1092.     }
  1093.     public function setCustomerType(int $customer_type): self
  1094.     {
  1095.         $this->customer_type $customer_type;
  1096.         return $this;
  1097.     }
  1098.     
  1099.     public function getCustomerTypeArray()
  1100.     {
  1101.         $type $this->customer_type;
  1102.         $values = array(
  1103.             self::TYPE_PRODUCTS_SERVICES,
  1104.             self::TYPE_DISTRIBUTORS,
  1105.             self::TYPE_CONSULTANTS,
  1106.             self::TYPE_CONTRACTORS,
  1107.             self::TYPE_ASSOCIATIONS,
  1108.             self::TYPE_MANUFACTURERS_REP,
  1109.             self::TYPE_RCS_PARTNERS
  1110.         );
  1111.         
  1112.         $return = array();
  1113.         
  1114.         foreach($values as $value) {
  1115.             if($value $type) {
  1116.                 switch ($value) {
  1117.                     case self::TYPE_PRODUCTS_SERVICES:
  1118.                         $return[] = self::TYPE_PRODUCTS_SERVICES_STRING;
  1119.                         break;
  1120.                     case self::TYPE_DISTRIBUTORS:
  1121.                         $return[] = self::TYPE_DISTRIBUTORS_STRING;
  1122.                         break;
  1123.                     case self::TYPE_CONSULTANTS:
  1124.                         $return[] = self::TYPE_CONSULTANTS_STRING;
  1125.                         break;
  1126.                     case self::TYPE_CONTRACTORS:
  1127.                         $return[] = self::TYPE_CONTRACTORS_STRING;
  1128.                         break;
  1129.                     case self::TYPE_ASSOCIATIONS:
  1130.                         $return[] = self::TYPE_ASSOCIATIONS_STRING;
  1131.                         break;
  1132.                     case self::TYPE_MANUFACTURERS_REP:
  1133.                         $return[] = self::TYPE_MANUFACTURERS_REP_STRING;
  1134.                         break;
  1135.                     case self::TYPE_RCS_PARTNERS:
  1136.                         $return[] = self::TYPE_RCS_PARTNERS_STRING;
  1137.                         break;
  1138.                     default:
  1139.                         break;
  1140.                 }
  1141.             }
  1142.         }
  1143.         return $return;
  1144.     }
  1145.     
  1146.     // Takes an array of strings
  1147.     public function setCustomerTypeArray($customer_type): self
  1148.     {
  1149.         $value 0;
  1150.         
  1151.         if(is_array($customer_type)){
  1152.             foreach($customer_type as $type) {
  1153.                 switch ($type) {
  1154.                     case self::TYPE_PRODUCTS_SERVICES_STRING:
  1155.                         $value += self::TYPE_PRODUCTS_SERVICES;
  1156.                         break;
  1157.                     case self::TYPE_DISTRIBUTORS_STRING:
  1158.                         $value += self::TYPE_DISTRIBUTORS;
  1159.                         break;
  1160.                     case self::TYPE_CONSULTANTS_STRING:
  1161.                         $value += self::TYPE_CONSULTANTS;
  1162.                         break;
  1163.                     case self::TYPE_CONTRACTORS_STRING:
  1164.                         $value += self::TYPE_CONTRACTORS;
  1165.                         break;
  1166.                     case self::TYPE_ASSOCIATIONS_STRING:
  1167.                         $value += self::TYPE_ASSOCIATIONS;
  1168.                         break;
  1169.                     case self::TYPE_MANUFACTURERS_REP_STRING:
  1170.                         $value += self::TYPE_MANUFACTURERS_REP;
  1171.                         break;
  1172.                     case self::TYPE_RCS_PARTNERS_STRING:
  1173.                         $value += self::TYPE_RCS_PARTNERS;
  1174.                         break;
  1175.                     default:
  1176.                         break;
  1177.                 }
  1178.             }
  1179.             
  1180.             $this->customer_type $value;
  1181.         }
  1182.         return $this;
  1183.     }
  1184.     
  1185.     public function getCustomerTypeString()
  1186.     {
  1187.         $customerTypes $this->getCustomerTypeArray();
  1188.         return implode(", "$customerTypes);
  1189.     }
  1190.     
  1191.     public function toArray ()
  1192.     {
  1193.         $return = [];
  1194.         foreach ($this as $key => $value) {
  1195.             $return[$key] = $value;
  1196.         }
  1197.         return $return;
  1198.     }
  1199.  
  1200.     /**
  1201.     * @return Collection|Content[]
  1202.     */
  1203.     public function getContents(): Collection
  1204.     {
  1205.         return $this->contents;
  1206.     }
  1207.     
  1208.     public function getContentsByType($type ""): Collection
  1209.     {
  1210.         $criteria Criteria::create()
  1211.             ->where(Criteria::expr()->eq("type"$type))
  1212.             ->andWhere(Criteria::expr()->eq("status""1"))
  1213.             ->orderBy(array("published_at" => Criteria::DESC));
  1214.         
  1215.         return $this->contents->matching($criteria);
  1216.     }
  1217.     public function addContent(Content $content): self
  1218.     {
  1219.         if (!$this->contents->contains($content)) {
  1220.             $this->contents[] = $content;
  1221.             $content->addCustomer($this);
  1222.         }
  1223.         
  1224.         return $this;
  1225.     }
  1226.     public function removeContent(Content $content): self
  1227.     {
  1228.      if ($this->contents->contains($content)) {
  1229.          $this->contents->removeElement($content);
  1230.          $content->removeCustomer($this);
  1231.      }
  1232.      
  1233.      return $this;
  1234.     }
  1235.     
  1236.     /**
  1237.     * @return Collection|Poll[]
  1238.     */
  1239.     public function getPolls(): Collection
  1240.     {
  1241.         return $this->polls;
  1242.     }
  1243.     
  1244.     public function addPoll(Poll $poll): self
  1245.     {
  1246.         if (!$this->polls->contains($poll)) {
  1247.             $this->polls[] = $poll;
  1248.             $poll->addCustomer($this);
  1249.         }
  1250.         
  1251.         return $this;
  1252.     }
  1253.     public function removePoll(Poll $poll): self
  1254.     {
  1255.      if ($this->polls->contains($poll)) {
  1256.          $this->polls->removeElement($poll);
  1257.          $poll->removeCustomer($this);
  1258.      }
  1259.      
  1260.      return $this;
  1261.     }
  1262.     
  1263.     /**
  1264.     * @return Collection|Quiz[]
  1265.     */
  1266.     public function getQuizzes(): Collection
  1267.     {
  1268.         return $this->quizzes;
  1269.     }
  1270.     
  1271.     public function addQuiz(Quiz $quiz): self
  1272.     {
  1273.         if (!$this->quizzes->contains($quiz)) {
  1274.             $this->quizzes[] = $quiz;
  1275.             $quiz->addCustomer($this);
  1276.         }
  1277.         
  1278.         return $this;
  1279.     }
  1280.     public function removeQuiz(Quiz $quiz): self
  1281.     {
  1282.      if ($this->quizzes->contains($quiz)) {
  1283.          $this->quizzes->removeElement($quiz);
  1284.          $quiz->removeCustomer($this);
  1285.      }
  1286.      
  1287.      return $this;
  1288.     }
  1289.     
  1290.     /**
  1291.     * @return Collection|Category[]
  1292.     */
  1293.     public function getCategories(): Collection
  1294.     {
  1295.         return $this->categories;
  1296.     }
  1297.  
  1298.     public function setCategories (Collection $categories): self {
  1299.         foreach ($categories as $category) {
  1300.             $this->addCategory($category);
  1301.         }
  1302.         return $this;
  1303.     }
  1304.     
  1305.     public function addCategory(Category $category): self
  1306.     {
  1307.         if (!$this->categories->contains($category)) {
  1308.             $this->categories[] = $category;
  1309.             $category->addCustomer($this);
  1310.         }
  1311.         return $this;
  1312.     }
  1313.  
  1314.     public function removeCategories(Category $category): self
  1315.     {
  1316.         if ($this->categories->contains($category)) {
  1317.             $this->categories->removeElement($category);
  1318.             $category->removeCustomer($this);
  1319.         }
  1320.         
  1321.         return $this;
  1322.     }
  1323.     
  1324.     public function getLatestContent($type ""$limit 3$cat ""):Collection
  1325.     {
  1326.         $criteria Criteria::create()->where(Criteria::expr()->eq("status""1"));
  1327.         if($type) {
  1328.             $criteria->andWhere(Criteria::expr()->eq("type"$type));
  1329.         }
  1330.         $criteria->orderBy(array("published_at" => Criteria::DESC));
  1331.         
  1332.         if($limit) {
  1333.             $criteria->setFirstResult(0);
  1334.             $criteria->setMaxResults($limit);
  1335.         }
  1336.         
  1337.         return $this->contents->matching($criteria);
  1338.     }
  1339.     
  1340.     // The directory twig template are using these
  1341.     //should find all and replace with getLatestContent() above and remove
  1342.     public function getPromosRebates($limit 4): Collection
  1343.     {
  1344.         return $this->getLatestContent(144);
  1345.     }
  1346.     public function getContestsGames($limit 4): Collection
  1347.     {
  1348.         return $this->getLatestContent(204);
  1349.     }
  1350.     public function getAwards($limit 4): Collection
  1351.     {
  1352.         return $this->getLatestContent(254);
  1353.     }
  1354.     public function getVideos($limit 4): Collection
  1355.     {
  1356.         return $this->getLatestContent(264);
  1357.     }
  1358.     public function getEbooks($limit 4): Collection
  1359.     {
  1360.         return $this->getLatestContent(19$limit);
  1361.     }
  1362.     public function getHUBContent($limit 4): Collection
  1363.     {
  1364.         return $this->getLatestContent(154);
  1365.     }
  1366.     public function getPodcasts($limit 4): Collection
  1367.     {
  1368.         return $this->getLatestContent(184);
  1369.     }
  1370.     
  1371.     public function getWebinars($limit 4): Collection
  1372.     {
  1373.         return $this->getLatestContent(84);
  1374.     }
  1375.     
  1376.     public function getClassifieds($limit 4): Collection
  1377.     {
  1378.         return $this->getLatestContent(34);
  1379.     }
  1380.     public function getScholarships($limit 4): Collection
  1381.     {
  1382.         return $this->getLatestContent(284);
  1383.     }
  1384.     
  1385.     // -=-=-=- Virtual Properties for EasyAdmin -=-=-=-
  1386.     
  1387.     public function getCustomerLevelString($site_id "")
  1388.     {
  1389.         switch($this->getCustomerLevel()) {
  1390.             case 1000
  1391.                 return "Premium";
  1392.             case 2000
  1393.                 return "Best";
  1394.             case 3000
  1395.                 return "Better";
  1396.             case 4000
  1397.                 return "Good";
  1398.             case 4001
  1399.                 return "R-Club";
  1400.             case 5000
  1401.                 return "Partner";
  1402.             case 6000
  1403.                 return "Standard";
  1404.             default:
  1405.                 return "Standard";
  1406.         }
  1407.     }
  1408.     
  1409.     public function getContactPerson()
  1410.     {
  1411.         //return $this->getContentMetaValueByKey("_job_location");
  1412.         
  1413.         //$directory = $this->getContentsByType(4)->first();
  1414.         $directory $this->getDirectoryContent();
  1415.         if($directory) {
  1416.             return $directory->getContentMetaValueByKey("_company_contact");
  1417.         }
  1418.         else {
  1419.             return null;
  1420.         }
  1421.         
  1422.     }
  1423.     
  1424.     public function getFeaturedEventTitle()
  1425.     {
  1426.         $directory $this->getDirectoryContent();
  1427.         if($directory) {
  1428.             return $directory->getContentMetaValueByKey("_featured_event_title");
  1429.         }
  1430.         else {
  1431.             return "";
  1432.         }
  1433.     }
  1434.     
  1435.     public function setFeaturedEventTitle($value)
  1436.     {
  1437.         $directory $this->getDirectoryContent();
  1438.         if($directory) {
  1439.             $directory->setContentmetum("_featured_event_title"$value);
  1440.         }
  1441.         return $this;
  1442.     }
  1443.     
  1444.     public function getFeaturedEventUrl()
  1445.     {
  1446.         $directory $this->getDirectoryContent();
  1447.         if($directory) {
  1448.             return $directory->getContentMetaValueByKey("_featured_event_url");
  1449.         }
  1450.         else {
  1451.             return "";
  1452.         }
  1453.     }
  1454.     
  1455.     public function setFeaturedEventUrl($value)
  1456.     {
  1457.         $directory $this->getDirectoryContent();
  1458.         if($directory) {
  1459.             $directory->setContentmetum("_featured_event_url"$value);
  1460.         }
  1461.         return $this;
  1462.     }
  1463.     
  1464.     public function getWebsiteTitle()
  1465.     {
  1466.         $directory $this->getDirectoryContent();
  1467.         if($directory) {
  1468.             return $directory->getContentMetaValueByKey("_directory_website_title");
  1469.         }
  1470.         else {
  1471.             return "";
  1472.         }
  1473.     }
  1474.     
  1475.     public function setWebsiteTitle($value)
  1476.     {
  1477.         $directory $this->getDirectoryContent();
  1478.         if($directory) {
  1479.             $directory->setContentmetum("_directory_website_title"$value);
  1480.         }
  1481.         return $this;
  1482.     }
  1483.     
  1484.     public function getWebsiteTitleText()
  1485.     {
  1486.         $title "";
  1487.         $directory $this->getDirectoryContent();
  1488.         if($directory) {
  1489.             $title $directory->getContentMetaValueByKey("_directory_website_title");
  1490.         }
  1491.         if(!$title) {
  1492.             $title $this->getWebsite();
  1493.         }
  1494.         return $title;
  1495.     }
  1496.     
  1497.     
  1498.     /**
  1499.      * @return Collection|MediaGroupItem[]
  1500.      */
  1501.     public function getMediaGroupItems(): Collection
  1502.     {
  1503.         return $this->mediaGroupItems;
  1504.     }
  1505.     public function addMediaGroupItem(MediaGroupItem $mediaGroupItem): self
  1506.     {
  1507.         if (!$this->mediaGroupItems->contains($mediaGroupItem)) {
  1508.             $this->mediaGroupItems[] = $mediaGroupItem;
  1509.             $mediaGroupItem->addCustomer($this);
  1510.         }
  1511.         return $this;
  1512.     }
  1513.     
  1514.     /*public function setMediaGroupItems (Collection $mediaGroupItems):self
  1515.     {
  1516.         $this->mediaGroupItems = $mediaGroupItems;
  1517.         return $this;
  1518.     }*/
  1519.     public function removeMediaGroupItem(MediaGroupItem $mediaGroupItem): self
  1520.     {
  1521.         if ($this->mediaGroupItems->contains($mediaGroupItem)) {
  1522.             $this->mediaGroupItems->removeElement($mediaGroupItem);
  1523.             $mediaGroupItem->removeCustomer($this);
  1524.         }
  1525.         return $this;
  1526.     }
  1527.     
  1528.     
  1529.     /**
  1530.      * @return Collection|Link[]
  1531.      */
  1532.     public function getLinks(): Collection
  1533.     {
  1534.         return $this->links;
  1535.     }
  1536.     public function addLink(Link $link): self
  1537.     {
  1538.         if (!$this->links->contains($link)) {
  1539.             $this->links[] = $link;
  1540.             $link->setCustomer($this);
  1541.         }
  1542.         return $this;
  1543.     }
  1544.     
  1545.     public function setLinks (Collection $links):self
  1546.     {
  1547.         $this->links $links;
  1548.         return $this;
  1549.     }
  1550.     public function removeLink(Link $link): self
  1551.     {
  1552.         if ($this->links->contains($link)) {
  1553.             $this->links->removeElement($link);
  1554.             // set the owning side to null (unless already changed)
  1555.             if ($link->getCustomer() === $this) {
  1556.                 $link->setCustomer(null);
  1557.             }
  1558.         }
  1559.         return $this;
  1560.     }
  1561.     
  1562.     /**
  1563.     * @return Collection|Product[]
  1564.     */
  1565.     public function getProducts(): Collection
  1566.     {
  1567.         return $this->products;
  1568.     }
  1569.     
  1570.     public function addProduct(Product $product): self
  1571.     {
  1572.         if (!$this->products->contains($product)) {
  1573.             $this->products[] = $product;
  1574.             $product->addCustomer($this);
  1575.         }
  1576.         
  1577.         return $this;
  1578.     }
  1579.     public function removeProduct(Product $product): self
  1580.     {
  1581.      if ($this->products->contains($product)) {
  1582.          $this->products->removeElement($product);
  1583.          $product->removeCustomer($this);
  1584.      }
  1585.      
  1586.      return $this;
  1587.     }
  1588.     
  1589.     public function getGiftStoreProducts($limit 3): Collection
  1590.     {
  1591.         $criteria Criteria::create()->where(Criteria::expr()->eq("status""1"));
  1592.         $criteria->andWhere(Criteria::expr()->eq("type""4"));
  1593.         $criteria->orderBy(array("published" => Criteria::DESC));
  1594.         
  1595.         if($limit) {
  1596.             $criteria->setFirstResult(0);
  1597.             $criteria->setMaxResults($limit);
  1598.         }
  1599.         
  1600.         return $this->products->matching($criteria);
  1601.     }
  1602.     
  1603.     
  1604.     /**
  1605.      * @return Collection|CustomerMeta[]
  1606.      */
  1607.     public function getCustomermeta(): Collection
  1608.     {
  1609.         return $this->customermeta;
  1610.     }
  1611.     
  1612.     //only works with unique keys, otherwise returns the first
  1613.     public function getCustomerMetaByKey ($key "")
  1614.     {
  1615.         foreach ($this->customermeta as $meta) {
  1616.             if ($meta->getMetakey() == $key) {
  1617.                 return $meta;
  1618.             }
  1619.         }
  1620.         return null;
  1621.     }
  1622.     
  1623.     
  1624.     public function getCustomerMetaValueByKey ($key "")
  1625.     {
  1626.         $meta $this->getCustomerMetaByKey($key);
  1627.         if ($meta) {
  1628.             return $meta->getMetavalue();
  1629.         }
  1630.         return "";
  1631.     }
  1632.     // sets the customer meta with the provided certain key / value, or changes it if one with that key already exists
  1633.     public function setCustomermetum($key ""$value "")
  1634.     {
  1635.         $meta $this->getCustomerMetaByKey($key);
  1636.         if ($meta) {
  1637.             $meta->setMetavalue($value);
  1638.         }
  1639.         else {
  1640.             $meta = new CustomerMeta();
  1641.             $meta->setMetakey($key);
  1642.             $meta->setMetavalue($value);
  1643.             $this->addCustomerMetum($meta);
  1644.         }
  1645.         
  1646.     }
  1647.     
  1648.     // adds customer meta with the provided key / value, even if one with that key already exists
  1649.     public function addCustomerMetumKV($key ""$value ""): self
  1650.     {
  1651.         $meta = new CustomerMeta();
  1652.         $meta->setMetakey($key);
  1653.         $meta->setMetavalue($value);
  1654.         $this->addCustomerMetum($meta);
  1655.         
  1656.         return $this;
  1657.     }
  1658.     
  1659.     public function removeCustomerMetumKV($key ""$value ""): self
  1660.     {
  1661.         foreach ($this->customermeta as $meta) {
  1662.             if ($meta->getMetakey() == $key && $meta->getMetavalue() == $value) {
  1663.                 $this->removeCustomermetum($meta);
  1664.             }
  1665.         }
  1666.         
  1667.         return $this;
  1668.     }
  1669.     
  1670.     public function addCustomerMetum(CustomerMeta $customermetum): self
  1671.     {        
  1672.         if (!$this->customermeta->contains($customermetum)) {
  1673.             $this->customermeta[] = $customermetum;
  1674.             $customermetum->setCustomer($this);
  1675.         }
  1676.         return $this;
  1677.     }
  1678.     
  1679.     public function removeCustomermetum(CustomerMeta $customermetum): self
  1680.     {
  1681.         if ($this->customermeta->contains($customermetum)) {
  1682.             $this->customermeta->removeElement($customermetum);
  1683.             // set the owning side to null (unless already changed)
  1684.             if ($customermetum->getCustomer() === $this) {
  1685.                 $customermetum->setCustomer(null);
  1686.             }
  1687.         }
  1688.         return $this;
  1689.     }
  1690.     
  1691.     // Content Impressions + Ad Impressions
  1692.     public function getMonthlyImpressions($year$month) {
  1693.         $json $this->getCustomerMetaValueByKey("monthly_impressions_v2");
  1694.         if(!$json) {
  1695.             return false;
  1696.         }
  1697.         $data json_decode($jsontrue);
  1698.         return isset($data[$year."-".$month]) ? $data[$year."-".$month] : false;
  1699.     }
  1700.     // Content Views
  1701.     public function getMonthlyViews($year$month) {
  1702.         $json $this->getCustomerMetaValueByKey("monthly_views_v2");
  1703.         if(!$json) {
  1704.             return false;
  1705.         }
  1706.         $data json_decode($jsontrue);
  1707.         return isset($data[$year."-".$month]) ? $data[$year."-".$month] : false;
  1708.     }
  1709.     
  1710.     // Ad Clicks + Link Clicks
  1711.     public function getMonthlyClicks($year$month) {
  1712.         $json $this->getCustomerMetaValueByKey("monthly_clicks_v2");
  1713.         if(!$json) {
  1714.             return false;
  1715.         }
  1716.         $data json_decode($jsontrue);
  1717.         return isset($data[$year."-".$month]) ? $data[$year."-".$month] : false;
  1718.     }
  1719.     public function setMonthlyImpressions($year$month$impressions) {
  1720.         $data = [];
  1721.         $json $this->getCustomerMetaValueByKey("monthly_impressions_v2");
  1722.         if($json) {
  1723.             $data json_decode($jsontrue);
  1724.         }
  1725.         $data[$year."-".$month] = $impressions;
  1726.         $this->setCustomermetum("monthly_impressions_v2"json_encode($data));
  1727.         
  1728.         return $this;
  1729.     }
  1730.     
  1731.     public function setMonthlyViews($year$month$views) {
  1732.         $data = [];
  1733.         $json $this->getCustomerMetaValueByKey("monthly_views_v2");
  1734.         if($json) {
  1735.             $data json_decode($jsontrue);
  1736.         }
  1737.         $data[$year."-".$month] = $views;
  1738.         $this->setCustomermetum("monthly_views_v2"json_encode($data));
  1739.         
  1740.         return $this;
  1741.     }
  1742.     
  1743.     public function setMonthlyClicks($year$month$clicks) {
  1744.         $data = [];
  1745.         $json $this->getCustomerMetaValueByKey("monthly_clicks_v2");
  1746.         if($json) {
  1747.             $data json_decode($jsontrue);
  1748.         }
  1749.         $data[$year."-".$month] = $clicks;
  1750.         $this->setCustomermetum("monthly_clicks_v2"json_encode($data));
  1751.         
  1752.         return $this;
  1753.     }
  1754.     /*
  1755.     //OLD:
  1756.     public function getMonthlyViews($year, $month) {
  1757.         $json = $this->getCustomerMetaValueByKey("monthly_views");
  1758.         if(!$json) {
  1759.             return false;
  1760.         }
  1761.         $data = json_decode($json, true);
  1762.         return isset($data[$year."-".$month]) ? $data[$year."-".$month] : false;
  1763.     }
  1764.     
  1765.     public function getMonthlyClicks($year, $month) {
  1766.         $json = $this->getCustomerMetaValueByKey("monthly_clicks");
  1767.         if(!$json) {
  1768.             return false;
  1769.         }
  1770.         $data = json_decode($json, true);
  1771.         return isset($data[$year."-".$month]) ? $data[$year."-".$month] : false;
  1772.     }
  1773.     
  1774.     public function setMonthlyViews($year, $month, $views) {
  1775.         $data = [];
  1776.         $json = $this->getCustomerMetaValueByKey("monthly_views");
  1777.         if($json) {
  1778.             $data = json_decode($json, true);
  1779.         }
  1780.         $data[$year."-".$month] = $views;
  1781.         $this->setCustomermetum("monthly_views", json_encode($data));
  1782.         
  1783.         return $this;
  1784.     }
  1785.     
  1786.     public function setMonthlyClicks($year, $month, $clicks) {
  1787.         $data = [];
  1788.         $json = $this->getCustomerMetaValueByKey("monthly_clicks");
  1789.         if($json) {
  1790.             $data = json_decode($json, true);
  1791.         }
  1792.         $data[$year."-".$month] = $clicks;
  1793.         $this->setCustomermetum("monthly_clicks", json_encode($data));
  1794.         
  1795.         return $this;
  1796.     }
  1797.     */
  1798.     
  1799.      public function getTypeWork(): string
  1800.     {
  1801.         return $this->type_work;
  1802.     }
  1803.     public function setTypeWork(string $type_work null): self
  1804.     {
  1805.         if (is_null($type_work)) {
  1806.             $type_work "";
  1807.         }
  1808.         
  1809.         $this->type_work $type_work;
  1810.         
  1811.         return $this;
  1812.     }
  1813.     
  1814.         /**
  1815.        * @return Collection|Site[]
  1816.        */
  1817.       public function getSite(): Collection
  1818.       {
  1819.           return $this->site;
  1820.       }
  1821.       
  1822.       public function getSites(): Collection
  1823.       {
  1824.           return $this->site;
  1825.       }
  1826.       public function addSite(Site $site): self
  1827.       {
  1828.           if (!$this->site->contains($site)) {
  1829.               $this->site[] = $site;
  1830.               $site->addCustomer($this);
  1831.             }
  1832.             return $this;
  1833.         }
  1834.       
  1835.       public function resetSite(): self
  1836.       {
  1837.           $this->site = new ArrayCollection();
  1838.           return $this;
  1839.       }
  1840.       
  1841.       public function removeSite(Site $site): self
  1842.   {
  1843.       if ($this->site->contains($site)) {
  1844.           $this->site->removeElement($site);
  1845.           $site->removeCustomer($this);
  1846.       }
  1847.       return $this;
  1848.   }
  1849.       
  1850.       
  1851.       public function getSiteTextShort()
  1852.       {
  1853.           $site_texts = [];
  1854.           foreach($this->getSite() as $s) {
  1855.               $site_texts[] = $s->getSiteTextShort();
  1856.           }
  1857.           return implode(", "$site_texts);
  1858.       }
  1859.       
  1860.       public function getSiteIds()
  1861.       {
  1862.           $site_ids = [];
  1863.           foreach($this->getSite() as $s) {
  1864.               $site_ids[] = $s->getId();
  1865.           }
  1866.           return $site_ids;
  1867.       }
  1868.     public function getLevels(): Collection
  1869.     {
  1870.         return $this->levels;
  1871.     }
  1872.     public function addLevel(CustomerSiteLevel $level): self
  1873.     {
  1874.         if (!$this->levels->contains($level)) {
  1875.             $this->levels[] = $level;
  1876.             $level->setCustomer($this);
  1877.         }
  1878.         return $this;
  1879.     }
  1880.     
  1881.     public function resetLevels(): self
  1882.     {
  1883.         $this->levels = new ArrayCollection();
  1884.         return $this;
  1885.     }
  1886.     
  1887.     
  1888. }