modules/XC/MailChimp/src/Model/MailChimpGroupName.php line 18

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace XC\MailChimp\Model;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * MailChimp mail list
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table  (name="mailchimp_list_group_name")
  13.  */
  14. class MailChimpGroupName extends \XLite\Model\AEntity
  15. {
  16.     /**
  17.      * List ID
  18.      *
  19.      * @var string
  20.      *
  21.      * @ORM\Id
  22.      * @ORM\Column (type="string", length=32)
  23.      */
  24.     protected $id '';
  25.     /**
  26.      * List name
  27.      *
  28.      * @var string
  29.      *
  30.      * @ORM\Column (type="string", length=128)
  31.      */
  32.     protected $name '';
  33.     /**
  34.      * List name
  35.      *
  36.      * @var integer
  37.      *
  38.      * @ORM\Column (type="integer", options={ "unsigned": true })
  39.      */
  40.     protected $subscriberCount 0;
  41.     /**
  42.      * MailChimp parent group
  43.      *
  44.      * @var \XC\MailChimp\Model\MailChimpGroup
  45.      *
  46.      * @ORM\ManyToOne (targetEntity="XC\MailChimp\Model\MailChimpGroup", inversedBy="names")
  47.      */
  48.     protected $group;
  49.     /**
  50.      * Profiles
  51.      *
  52.      * @var \Doctrine\Common\Collections\Collection
  53.      *
  54.      * @ORM\ManyToMany (targetEntity="XLite\Model\Profile", inversedBy="mail_chimp_interests")
  55.      * @ORM\JoinTable  (
  56.      *      name="mailchimp_profile_interests",
  57.      *      joinColumns={@ORM\JoinColumn(name="group_name_id", referencedColumnName="id", onDelete="CASCADE")},
  58.      *      inverseJoinColumns={@ORM\JoinColumn(name="profile_id", referencedColumnName="profile_id", onDelete="CASCADE")}
  59.      * )
  60.      */
  61.     protected $profiles;
  62.     /**
  63.      * Subscribed by default
  64.      *
  65.      * @var boolean
  66.      *
  67.      * @ORM\Column (type="boolean")
  68.      */
  69.     protected $subscribeByDefault false;
  70.     /**
  71.      * Enabled
  72.      *
  73.      * @var boolean
  74.      *
  75.      * @ORM\Column (type="boolean")
  76.      */
  77.     protected $enabled true;
  78.     /**
  79.      * Constructor
  80.      *
  81.      * @param array $data Entity properties OPTIONAL
  82.      */
  83.     public function __construct(array $data = [])
  84.     {
  85.         $this->profiles     = new \Doctrine\Common\Collections\ArrayCollection();
  86.         parent::__construct($data);
  87.     }
  88.     /**
  89.      * Set id
  90.      *
  91.      * @param string $id
  92.      * @return MailChimpGroupName
  93.      */
  94.     public function setId($id)
  95.     {
  96.         $this->id $id;
  97.         return $this;
  98.     }
  99.     /**
  100.      * Get id
  101.      *
  102.      * @return string
  103.      */
  104.     public function getId()
  105.     {
  106.         return $this->id;
  107.     }
  108.     /**
  109.      * @return string
  110.      */
  111.     public function getName()
  112.     {
  113.         return $this->name;
  114.     }
  115.     /**
  116.      * @param string $name
  117.      *
  118.      * @return MailChimpGroupName
  119.      */
  120.     public function setName($name)
  121.     {
  122.         $this->name $name;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return int
  127.      */
  128.     public function getSubscribersCount()
  129.     {
  130.         return $this->subscriberCount;
  131.     }
  132.     /**
  133.      * @param int $subscriberCount
  134.      *
  135.      * @return MailChimpGroupName
  136.      */
  137.     public function setSubscribersCount($subscriberCount)
  138.     {
  139.         $this->subscriberCount $subscriberCount;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return MailChimpGroup
  144.      */
  145.     public function getGroup()
  146.     {
  147.         return $this->group;
  148.     }
  149.     /**
  150.      * @param MailChimpGroup $group
  151.      *
  152.      * @return MailChimpGroupName
  153.      */
  154.     public function setGroup($group)
  155.     {
  156.         $this->group $group;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return int
  161.      */
  162.     public function getSubscriberCount()
  163.     {
  164.         return $this->subscriberCount;
  165.     }
  166.     /**
  167.      * @param int $subscriberCount
  168.      */
  169.     public function setSubscriberCount($subscriberCount)
  170.     {
  171.         $this->subscriberCount $subscriberCount;
  172.     }
  173.     /**
  174.      * @return bool
  175.      */
  176.     public function getSubscribeByDefault()
  177.     {
  178.         return $this->subscribeByDefault;
  179.     }
  180.     /**
  181.      * @param boolean $subscribeByDefault
  182.      */
  183.     public function setSubscribeByDefault($subscribeByDefault)
  184.     {
  185.         $this->subscribeByDefault $subscribeByDefault;
  186.         return $this;
  187.     }
  188.     /**
  189.      * @return boolean
  190.      */
  191.     public function getEnabled()
  192.     {
  193.         return $this->enabled;
  194.     }
  195.     /**
  196.      * @param boolean $enabled
  197.      */
  198.     public function setEnabled($enabled)
  199.     {
  200.         $this->enabled = (bool)$enabled;
  201.     }
  202.     /**
  203.      * Check if provided profile is subscribes to this list
  204.      *
  205.      * @param \XLite\Model\Profile|null $profile Profile
  206.      *
  207.      * @return boolean
  208.      */
  209.     public function isProfileChecked($profile)
  210.     {
  211.         return isset($profile)
  212.             ? $this->getRepository()->isProfileChecked($this$profile)
  213.             : $this->getSubscribeByDefault();
  214.     }
  215.     /**
  216.      * Add profiles
  217.      *
  218.      * @param \XLite\Model\Profile $profiles
  219.      * @return MailChimpGroupName
  220.      */
  221.     public function addProfiles(\XLite\Model\Profile $profiles)
  222.     {
  223.         $this->profiles[] = $profiles;
  224.         return $this;
  225.     }
  226.     /**
  227.      * Get profiles
  228.      *
  229.      * @return \Doctrine\Common\Collections\Collection
  230.      */
  231.     public function getProfiles()
  232.     {
  233.         return $this->profiles;
  234.     }
  235. }