src/Entity/Message.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints as AppAssert;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Exception;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * Class Message
  11.  *
  12.  * @ORM\Entity(repositoryClass="App\Repository\MessageRepository")
  13.  * @ORM\Table(name="malys_message")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  * @package App\Entity
  16.  * @AppAssert\Message
  17.  */
  18. class Message
  19. {
  20.     /**
  21.      * @var integer
  22.      *
  23.      * @ORM\Column(name="id", type="integer")
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      */
  27.     protected $id;
  28.     /**
  29.      * @var string
  30.      *
  31.      * @ORM\Column(name="type", type="string", length=255, nullable=false)
  32.      */
  33.     protected $type "manual";
  34.     /**
  35.      * @var string
  36.      *
  37.      * @ORM\Column(name="title", type="string", length=255, nullable=false)
  38.      * @Assert\NotBlank
  39.      */
  40.     protected $title;
  41.     /**
  42.      * @var string
  43.      *
  44.      * @ORM\Column(name="subtitle", type="string", length=255, nullable=true)
  45.      */
  46.     protected $subtitle;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="btn_discard_label", type="string", length=255, nullable=true)
  51.      * @Assert\NotBlank
  52.      */
  53.     protected $btn_discard_label "Cacher";
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(name="title_icon", type="string", length=255, nullable=true)
  58.      */
  59.     protected $titleIcon;
  60.     /**
  61.      * @var string
  62.      *
  63.      * @ORM\Column(name="btn_cta_label", type="string", length=255, nullable=true)
  64.      */
  65.     protected $btn_cta_label;
  66.     /**
  67.      * @var string
  68.      *
  69.      * @ORM\Column(name="btn_cta_url", type="string", length=255, nullable=true)
  70.      * @Assert\Url
  71.      */
  72.     protected $btn_cta_url;
  73.     /**
  74.      * @var DateTime
  75.      *
  76.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  77.      */
  78.     protected $createdAt;
  79.     /**
  80.      * @var DateTime
  81.      *
  82.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  83.      */
  84.     protected $updatedAt;
  85.     /**
  86.      * @var DateTime
  87.      *
  88.      * @ORM\Column(name="start", type="datetime", nullable=true)
  89.      */
  90.     protected $start;
  91.     /**
  92.      * @var DateTime
  93.      *
  94.      * @ORM\Column(name="end", type="datetime", nullable=true)
  95.      */
  96.     protected $end;
  97.     /**
  98.      * @ORM\ManyToMany(targetEntity="App\Entity\Customer")
  99.      * @ORM\JoinTable(name="malys_message_rule_doesworkforcustomer")
  100.      */
  101.     protected $ruleDoesWorkForCustomers;
  102.     /**
  103.      * @ORM\ManyToMany(targetEntity="App\Entity\Supplier")
  104.      * @ORM\JoinTable(name="malys_message_rule_doesworkwithsupplier")
  105.      */
  106.     protected $ruleDoesWorkWithSuppliers;
  107.     /**
  108.      * @ORM\ManyToMany(targetEntity="App\Entity\Supplier")
  109.      * @ORM\JoinTable(name="malys_message_rule_doesnotworkwithsupplier")
  110.      */
  111.     protected $ruleDoesNotWorkWithSuppliers;
  112.     /**
  113.      * One Message has many MessageMatches
  114.      * @ORM\OneToMany(targetEntity="App\Entity\MessageMatch", mappedBy="message", cascade={"persist"})
  115.      */
  116.     protected $messageMatches;
  117.     /**
  118.      * @var boolean
  119.      *
  120.      * @ORM\Column(name="enabled", type="boolean", options={"default" : true}, nullable=false)
  121.      */
  122.     protected $enabled;
  123.     /**
  124.      * @var string
  125.      *
  126.      * @ORM\Column(name="color", type="string", length=255, nullable=true)
  127.      */
  128.     protected $color;
  129.     /**
  130.      * @ORM\Column(name="extra_data" ,type="array", nullable=true)
  131.      */
  132.     protected $extraData = [];
  133.     /**
  134.      * @var boolean
  135.      *
  136.      * @ORM\Column(name="with_notification", type="boolean", options={"default" : false}, nullable=true)
  137.      */
  138.     protected $withNotification;
  139.     public function __construct()
  140.     {
  141.         $this->ruleDoesWorkForCustomers     = new ArrayCollection();
  142.         $this->ruleDoesWorkWithSuppliers    = new ArrayCollection();
  143.         $this->ruleDoesNotWorkWithSuppliers = new ArrayCollection();
  144.         $this->messageMatches               = new ArrayCollection();
  145.         $this->start                        = new DateTime('now');
  146.         $this->end                          = new DateTime('now + 7 days');
  147.         $this->enabled                      true;
  148.         $this->withNotification             false;
  149.     }
  150.     /**
  151.      * @return int
  152.      */
  153.     public function getId()
  154.     {
  155.         return $this->id;
  156.     }
  157.     /**
  158.      * @param int $id
  159.      */
  160.     public function setId($id)
  161.     {
  162.         $this->id $id;
  163.     }
  164.     /**
  165.      * @return string
  166.      */
  167.     public function getTitle()
  168.     {
  169.         return $this->title;
  170.     }
  171.     /**
  172.      * @param string $title
  173.      */
  174.     public function setTitle($title)
  175.     {
  176.         $this->title $title;
  177.     }
  178.     /**
  179.      * @return string
  180.      */
  181.     public function getSubtitle()
  182.     {
  183.         return $this->subtitle;
  184.     }
  185.     /**
  186.      * @param string $subtitle
  187.      */
  188.     public function setSubtitle($subtitle)
  189.     {
  190.         $this->subtitle $subtitle;
  191.     }
  192.     public function isBtnDiscardEnabled()
  193.     {
  194.         return $this->btn_discard_label true false;
  195.     }
  196.     /**
  197.      * @return string
  198.      */
  199.     public function getBtnDiscardLabel()
  200.     {
  201.         return $this->btn_discard_label;
  202.     }
  203.     /**
  204.      * @param string $btn_discard_label
  205.      */
  206.     public function setBtnDiscardLabel($btn_discard_label)
  207.     {
  208.         $this->btn_discard_label $btn_discard_label;
  209.     }
  210.     public function isBtnCtaEnabled()
  211.     {
  212.         return $this->btn_cta_label true false;
  213.     }
  214.     /**
  215.      * @return string
  216.      */
  217.     public function getTitleIcon()
  218.     {
  219.         return $this->titleIcon;
  220.     }
  221.     /**
  222.      * @param string $titleIcon
  223.      */
  224.     public function setTitleIcon(string $titleIcon): void
  225.     {
  226.         $this->titleIcon $titleIcon;
  227.     }
  228.     /**
  229.      * @return string
  230.      */
  231.     public function getBtnCtaLabel()
  232.     {
  233.         return $this->btn_cta_label;
  234.     }
  235.     /**
  236.      * @param string $btn_cta_label
  237.      */
  238.     public function setBtnCtaLabel($btn_cta_label)
  239.     {
  240.         $this->btn_cta_label $btn_cta_label;
  241.     }
  242.     /**
  243.      * @return string
  244.      */
  245.     public function getBtnCtaUrl()
  246.     {
  247.         return $this->btn_cta_url;
  248.     }
  249.     /**
  250.      * @param string $btn_cta_url
  251.      */
  252.     public function setBtnCtaUrl($btn_cta_url)
  253.     {
  254.         $this->btn_cta_url $btn_cta_url;
  255.     }
  256.     /**
  257.      * @return DateTime
  258.      */
  259.     public function getStart()
  260.     {
  261.         return $this->start;
  262.     }
  263.     /**
  264.      * @param DateTime $start
  265.      */
  266.     public function setStart(DateTime $start): void
  267.     {
  268.         $this->start $start;
  269.     }
  270.     /**
  271.      * @return DateTime
  272.      */
  273.     public function getEnd()
  274.     {
  275.         return $this->end;
  276.     }
  277.     /**
  278.      * @param DateTime $end
  279.      */
  280.     public function setEnd(DateTime $end): void
  281.     {
  282.         $this->end $end;
  283.     }
  284.     /**
  285.      * @return ArrayCollection
  286.      */
  287.     public function getRuleDoesWorkForCustomers()
  288.     {
  289.         return $this->ruleDoesWorkForCustomers;
  290.     }
  291.     /**
  292.      * @param $customers
  293.      */
  294.     public function setRuleDoesWorkForCustomers($customers)
  295.     {
  296.         $this->ruleDoesWorkForCustomers $customers;
  297.     }
  298.     public function addRuleDoesWorkForCustomer(Customer $customer)
  299.     {
  300.         if (! $this->ruleDoesWorkForCustomers->contains($customer)) {
  301.             $this->ruleDoesWorkForCustomers->add($customer);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removeRuleDoesWorkForCustomer(Customer $customer)
  306.     {
  307.         $this->ruleDoesWorkForCustomers->removeElement($customer);
  308.         return $this;
  309.     }
  310.     /**
  311.      * @return ArrayCollection
  312.      */
  313.     public function getRuleDoesWorkWithSuppliers()
  314.     {
  315.         return $this->ruleDoesWorkWithSuppliers;
  316.     }
  317.     /**
  318.      * @param $suppliers
  319.      */
  320.     public function setRuleDoesWorkWithSuppliers($suppliers)
  321.     {
  322.         $this->ruleDoesWorkWithSuppliers $suppliers;
  323.     }
  324.     public function addRuleDoesWorkWithSupplier(Supplier $supplier)
  325.     {
  326.         if (! $this->ruleDoesWorkWithSuppliers->contains($supplier)) {
  327.             $this->ruleDoesWorkWithSuppliers->add($supplier);
  328.         }
  329.         return $this;
  330.     }
  331.     public function removeRuleDoesWorkWithSupplier(Supplier $supplier)
  332.     {
  333.         $this->ruleDoesWorkWithSuppliers->removeElement($supplier);
  334.         return $this;
  335.     }
  336.     /**
  337.      * @return ArrayCollection
  338.      */
  339.     public function getRuleDoesNotWorkWithSuppliers()
  340.     {
  341.         return $this->ruleDoesNotWorkWithSuppliers;
  342.     }
  343.     /**
  344.      * @param $suppliers
  345.      */
  346.     public function setRuleDoesNotWorkWithSuppliers($suppliers)
  347.     {
  348.         $this->ruleDoesNotWorkWithSuppliers $suppliers;
  349.     }
  350.     public function addRuleDoesNotWorkWithSupplier(Supplier $supplier)
  351.     {
  352.         if (! $this->ruleDoesNotWorkWithSuppliers->contains($supplier)) {
  353.             $this->ruleDoesNotWorkWithSuppliers->add($supplier);
  354.         }
  355.         return $this;
  356.     }
  357.     public function removeRuleDoesNotWorkWithSupplier(Supplier $supplier)
  358.     {
  359.         $this->ruleDoesNotWorkWithSuppliers->removeElement($supplier);
  360.         return $this;
  361.     }
  362.     /**
  363.      * @return ArrayCollection
  364.      */
  365.     public function getMessageMatches()
  366.     {
  367.         return $this->messageMatches;
  368.     }
  369.     /**
  370.      * @param ArrayCollection $messageMatches
  371.      *
  372.      * @return Message
  373.      */
  374.     public function setMessageMatches($messageMatches)
  375.     {
  376.         $this->messageMatches $messageMatches;
  377.         return $this;
  378.     }
  379.     /**
  380.      * @param MessageMatch $messageMatch
  381.      *
  382.      * @return Message
  383.      */
  384.     public function addMessageMatch($messageMatch)
  385.     {
  386.         $this->messageMatches->add($messageMatch);
  387.         return $this;
  388.     }
  389.     /**
  390.      * @param MessageMatch $messageMatch
  391.      */
  392.     public function removeMessageMatch($messageMatch)
  393.     {
  394.         if (! $this->messageMatches->contains($messageMatch)) {
  395.             return $this;
  396.         }
  397.         $this->messageMatches->removeElement($messageMatch);
  398.     }
  399.     /**
  400.      * @return bool
  401.      */
  402.     public function isEnabled()
  403.     {
  404.         return $this->enabled;
  405.     }
  406.     /**
  407.      * @param bool $enabled
  408.      */
  409.     public function setEnabled($enabled)
  410.     {
  411.         $this->enabled $enabled;
  412.     }
  413.     /**
  414.      * @return mixed
  415.      */
  416.     public function getExtraData()
  417.     {
  418.         return $this->extraData;
  419.     }
  420.     /**
  421.      * @param mixed $extraData
  422.      */
  423.     public function setExtraData($extraData): void
  424.     {
  425.         $this->extraData $extraData;
  426.     }
  427.     /**
  428.      * @return string
  429.      */
  430.     public function getType(): string
  431.     {
  432.         return $this->type;
  433.     }
  434.     /**
  435.      * @param string $type
  436.      */
  437.     public function setType(string $type): void
  438.     {
  439.         $this->type $type;
  440.     }
  441.     /**
  442.      * @return string
  443.      */
  444.     public function getColor()
  445.     {
  446.         return $this->color;
  447.     }
  448.     /**
  449.      * @param string $color
  450.      */
  451.     public function setColor(string $color): void
  452.     {
  453.         $this->color $color;
  454.     }
  455.     /**
  456.      * @return DateTime
  457.      */
  458.     public function getCreatedAt()
  459.     {
  460.         return $this->createdAt;
  461.     }
  462.     /**
  463.      * @return Message
  464.      * @ORM\PrePersist()
  465.      * @throws Exception
  466.      */
  467.     public function setCreatedAt()
  468.     {
  469.         $this->createdAt = new DateTime();
  470.         $this->updatedAt = new DateTime();
  471.         return $this;
  472.     }
  473.     /**
  474.      * @return DateTime
  475.      */
  476.     public function getUpdatedAt()
  477.     {
  478.         return $this->updatedAt;
  479.     }
  480.     /**
  481.      * Set updatedAt
  482.      *
  483.      * @return Message
  484.      * @ORM\PreUpdate
  485.      * @throws Exception
  486.      */
  487.     public function setUpdatedAt()
  488.     {
  489.         $this->updatedAt = new DateTime();
  490.         return $this;
  491.     }
  492.     /**
  493.      * @return bool
  494.      */
  495.     public function isWithNotification(): bool
  496.     {
  497.         return $this->withNotification;
  498.     }
  499.     /**
  500.      * @param bool $withNotification
  501.      */
  502.     public function setWithNotification(bool $withNotification): void
  503.     {
  504.         $this->withNotification $withNotification;
  505.     }
  506. }