vendor/rawafed/contact-forms-bundle/Entity/ContactUsCategory.php line 17

Open in your IDE?
  1. <?php
  2. namespace Rawafed\ContactFormsBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Rawafed\CommonsBundle\DoctrineExtensions\Localizable;
  7. use JMS\Serializer\Annotation as Serializer;
  8. /**
  9.  * ContactUsCategory
  10.  *
  11.  * @ORM\Table(indexes={@ORM\Index(name="idx_name", columns={"name"})})
  12.  * @ORM\Entity(repositoryClass="Rawafed\ContactFormsBundle\Entity\Repository\ContactUsCategoryRepository")
  13.  */
  14. class ContactUsCategory extends Localizable
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\Column(type="integer")
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var string
  24.      *
  25.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  26.      * @Assert\NotBlank()
  27.      */
  28.     private $name;
  29.     /**
  30.      * @var string
  31.      *
  32.      * @ORM\Column(type="string", length=127, nullable=true)
  33.      */
  34.     private $tag;
  35.     /**
  36.      * @ORM\Column(name="is_enabled", type="boolean", options={"default" = true})
  37.      * @Serializer\Exclude
  38.      */
  39.     private $enabled true;
  40.     /**
  41.      * @var bool
  42.      *
  43.      * @ORM\Column(type="boolean", options={"default" = false})
  44.      * @Serializer\Exclude
  45.      */
  46.     private $is_system false;
  47.     /**
  48.      * @var bool
  49.      *
  50.      * @ORM\Column(type="boolean", options={"default" = false})
  51.      */
  52.     private $has_attachments false;
  53.     /**
  54.      * @ORM\Column(type="integer", options={"default" = 65535})
  55.      * @Serializer\Exclude
  56.      */
  57.     private $view_order 65535;
  58.      /**
  59.      * @ORM\OneToMany(targetEntity="ContactUsMessage", mappedBy="category")
  60.       * @Serializer\Exclude
  61.      **/
  62.     protected $messages;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity="ContactUsEmailRecipient", mappedBy="category", orphanRemoval=true, cascade={"all"})
  65.      * @ORM\OrderBy({"type" = "ASC", "email" = "Asc"})
  66.      * @Assert\Valid()
  67.      * @Assert\NotNull()
  68.      * @Assert\Count(min = 1, minMessage = "contactforms.messages.email_recipients_are_mandatory")
  69.      * @Serializer\Exclude
  70.      **/
  71.     protected $emailRecipients;
  72.     
  73.     public function __construct() 
  74.     {
  75.         $this->messages = new ArrayCollection();
  76.         $this->emailRecipients = new ArrayCollection();
  77.     }
  78.     /**
  79.      * Get id
  80.      *
  81.      * @return integer 
  82.      */
  83.     public function getId()
  84.     {
  85.         return $this->id;
  86.     }
  87.     /**
  88.      * Set name
  89.      *
  90.      * @param string $name
  91.      * @return ContactUsCategory
  92.      */
  93.     public function setName($name)
  94.     {
  95.         $this->name $name;
  96.         return $this;
  97.     }
  98.     /**
  99.      * Get name
  100.      *
  101.      * @return string 
  102.      */
  103.     public function getName()
  104.     {
  105.         return $this->name;
  106.     }
  107.     /**
  108.      * Set tag
  109.      *
  110.      * @param string $tag
  111.      * @return ContactUsCategory
  112.      */
  113.     public function setTag($tag)
  114.     {
  115.         $this->tag $tag;
  116.         return $this;
  117.     }
  118.     /**
  119.      * Get tag
  120.      *
  121.      * @return string 
  122.      */
  123.     public function getTag()
  124.     {
  125.         return $this->tag;
  126.     }
  127.     /**
  128.      * Set enabled
  129.      *
  130.      * @param boolean $enabled
  131.      * @return ContactUsCategory
  132.      */
  133.     public function setEnabled($enabled)
  134.     {
  135.         $this->enabled $enabled;
  136.     
  137.         return $this;
  138.     }
  139.     /**
  140.      * Get enabled
  141.      *
  142.      * @return boolean 
  143.      */
  144.     public function isEnabled()
  145.     {
  146.         return $this->enabled;
  147.     }
  148.     /**
  149.      * @return bool
  150.      */
  151.     public function isSystem()
  152.     {
  153.         return $this->is_system;
  154.     }
  155.     /**
  156.      * @param bool $is_system
  157.      * @return ContactUsCategory
  158.      */
  159.     public function setIsSystem($is_system)
  160.     {
  161.         $this->is_system $is_system;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return bool
  166.      */
  167.     public function hasAttachments()
  168.     {
  169.         return $this->has_attachments;
  170.     }
  171.     /**
  172.      * @param bool $has_attachments
  173.      * @return ContactUsCategory
  174.      */
  175.     public function setHasAttachments($has_attachments)
  176.     {
  177.         $this->has_attachments $has_attachments;
  178.         return $this;
  179.     }
  180.     /**
  181.      * Set view_order
  182.      *
  183.      * @param integer $viewOrder
  184.      * @return ContactUsCategory
  185.      */
  186.     public function setViewOrder($viewOrder)
  187.     {
  188.         $this->view_order $viewOrder;
  189.     
  190.         return $this;
  191.     }
  192.     /**
  193.      * Get view_order
  194.      *
  195.      * @return integer 
  196.      */
  197.     public function getViewOrder()
  198.     {
  199.         return $this->view_order;
  200.     }
  201.     public function getMessages()
  202.     {
  203.         return $this->messages;
  204.     }
  205.     
  206.     public function getEmailRecipients()
  207.     {
  208.         return $this->emailRecipients;
  209.     }
  210.     
  211.     public function getEmailRecipientById($id)
  212.     {
  213.         foreach($this->getEmailRecipients() as $recipient) {
  214.             if($recipient->getId() == $id) {
  215.                 return $recipient;
  216.             }
  217.         }
  218.         return null;
  219.     }
  220.     public function addEmailRecipient(ContactUsEmailRecipient $emailRecipient
  221.     {
  222.         $emailRecipient->setCategory($this);
  223.         $this->emailRecipients->add($emailRecipient);
  224.         return $this;
  225.     }
  226.     
  227.     public function removeEmailRecipient(ContactUsEmailRecipient $emailRecipient
  228.     {
  229.         $this->emailRecipients->removeElement($emailRecipient);
  230.         return $this;
  231.     }
  232.     
  233.     
  234.     public function __toString() 
  235.     {
  236.         return $this->getName();
  237.     }
  238. }