<?php
namespace App\Entity;
use App\Validator\Constraints as AppAssert;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Message
*
* @ORM\Entity(repositoryClass="App\Repository\MessageRepository")
* @ORM\Table(name="malys_message")
* @ORM\HasLifecycleCallbacks()
* @package App\Entity
* @AppAssert\Message
*/
class Message
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=255, nullable=false)
*/
protected $type = "manual";
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=false)
* @Assert\NotBlank
*/
protected $title;
/**
* @var string
*
* @ORM\Column(name="subtitle", type="string", length=255, nullable=true)
*/
protected $subtitle;
/**
* @var string
*
* @ORM\Column(name="btn_discard_label", type="string", length=255, nullable=true)
* @Assert\NotBlank
*/
protected $btn_discard_label = "Cacher";
/**
* @var string
*
* @ORM\Column(name="title_icon", type="string", length=255, nullable=true)
*/
protected $titleIcon;
/**
* @var string
*
* @ORM\Column(name="btn_cta_label", type="string", length=255, nullable=true)
*/
protected $btn_cta_label;
/**
* @var string
*
* @ORM\Column(name="btn_cta_url", type="string", length=255, nullable=true)
* @Assert\Url
*/
protected $btn_cta_url;
/**
* @var DateTime
*
* @ORM\Column(name="createdAt", type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var DateTime
*
* @ORM\Column(name="updatedAt", type="datetime", nullable=true)
*/
protected $updatedAt;
/**
* @var DateTime
*
* @ORM\Column(name="start", type="datetime", nullable=true)
*/
protected $start;
/**
* @var DateTime
*
* @ORM\Column(name="end", type="datetime", nullable=true)
*/
protected $end;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Customer")
* @ORM\JoinTable(name="malys_message_rule_doesworkforcustomer")
*/
protected $ruleDoesWorkForCustomers;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Supplier")
* @ORM\JoinTable(name="malys_message_rule_doesworkwithsupplier")
*/
protected $ruleDoesWorkWithSuppliers;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Supplier")
* @ORM\JoinTable(name="malys_message_rule_doesnotworkwithsupplier")
*/
protected $ruleDoesNotWorkWithSuppliers;
/**
* One Message has many MessageMatches
* @ORM\OneToMany(targetEntity="App\Entity\MessageMatch", mappedBy="message", cascade={"persist"})
*/
protected $messageMatches;
/**
* @var boolean
*
* @ORM\Column(name="enabled", type="boolean", options={"default" : true}, nullable=false)
*/
protected $enabled;
/**
* @var string
*
* @ORM\Column(name="color", type="string", length=255, nullable=true)
*/
protected $color;
/**
* @ORM\Column(name="extra_data" ,type="array", nullable=true)
*/
protected $extraData = [];
/**
* @var boolean
*
* @ORM\Column(name="with_notification", type="boolean", options={"default" : false}, nullable=true)
*/
protected $withNotification;
public function __construct()
{
$this->ruleDoesWorkForCustomers = new ArrayCollection();
$this->ruleDoesWorkWithSuppliers = new ArrayCollection();
$this->ruleDoesNotWorkWithSuppliers = new ArrayCollection();
$this->messageMatches = new ArrayCollection();
$this->start = new DateTime('now');
$this->end = new DateTime('now + 7 days');
$this->enabled = true;
$this->withNotification = false;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getSubtitle()
{
return $this->subtitle;
}
/**
* @param string $subtitle
*/
public function setSubtitle($subtitle)
{
$this->subtitle = $subtitle;
}
public function isBtnDiscardEnabled()
{
return $this->btn_discard_label ? true : false;
}
/**
* @return string
*/
public function getBtnDiscardLabel()
{
return $this->btn_discard_label;
}
/**
* @param string $btn_discard_label
*/
public function setBtnDiscardLabel($btn_discard_label)
{
$this->btn_discard_label = $btn_discard_label;
}
public function isBtnCtaEnabled()
{
return $this->btn_cta_label ? true : false;
}
/**
* @return string
*/
public function getTitleIcon()
{
return $this->titleIcon;
}
/**
* @param string $titleIcon
*/
public function setTitleIcon(string $titleIcon): void
{
$this->titleIcon = $titleIcon;
}
/**
* @return string
*/
public function getBtnCtaLabel()
{
return $this->btn_cta_label;
}
/**
* @param string $btn_cta_label
*/
public function setBtnCtaLabel($btn_cta_label)
{
$this->btn_cta_label = $btn_cta_label;
}
/**
* @return string
*/
public function getBtnCtaUrl()
{
return $this->btn_cta_url;
}
/**
* @param string $btn_cta_url
*/
public function setBtnCtaUrl($btn_cta_url)
{
$this->btn_cta_url = $btn_cta_url;
}
/**
* @return DateTime
*/
public function getStart()
{
return $this->start;
}
/**
* @param DateTime $start
*/
public function setStart(DateTime $start): void
{
$this->start = $start;
}
/**
* @return DateTime
*/
public function getEnd()
{
return $this->end;
}
/**
* @param DateTime $end
*/
public function setEnd(DateTime $end): void
{
$this->end = $end;
}
/**
* @return ArrayCollection
*/
public function getRuleDoesWorkForCustomers()
{
return $this->ruleDoesWorkForCustomers;
}
/**
* @param $customers
*/
public function setRuleDoesWorkForCustomers($customers)
{
$this->ruleDoesWorkForCustomers = $customers;
}
public function addRuleDoesWorkForCustomer(Customer $customer)
{
if (! $this->ruleDoesWorkForCustomers->contains($customer)) {
$this->ruleDoesWorkForCustomers->add($customer);
}
return $this;
}
public function removeRuleDoesWorkForCustomer(Customer $customer)
{
$this->ruleDoesWorkForCustomers->removeElement($customer);
return $this;
}
/**
* @return ArrayCollection
*/
public function getRuleDoesWorkWithSuppliers()
{
return $this->ruleDoesWorkWithSuppliers;
}
/**
* @param $suppliers
*/
public function setRuleDoesWorkWithSuppliers($suppliers)
{
$this->ruleDoesWorkWithSuppliers = $suppliers;
}
public function addRuleDoesWorkWithSupplier(Supplier $supplier)
{
if (! $this->ruleDoesWorkWithSuppliers->contains($supplier)) {
$this->ruleDoesWorkWithSuppliers->add($supplier);
}
return $this;
}
public function removeRuleDoesWorkWithSupplier(Supplier $supplier)
{
$this->ruleDoesWorkWithSuppliers->removeElement($supplier);
return $this;
}
/**
* @return ArrayCollection
*/
public function getRuleDoesNotWorkWithSuppliers()
{
return $this->ruleDoesNotWorkWithSuppliers;
}
/**
* @param $suppliers
*/
public function setRuleDoesNotWorkWithSuppliers($suppliers)
{
$this->ruleDoesNotWorkWithSuppliers = $suppliers;
}
public function addRuleDoesNotWorkWithSupplier(Supplier $supplier)
{
if (! $this->ruleDoesNotWorkWithSuppliers->contains($supplier)) {
$this->ruleDoesNotWorkWithSuppliers->add($supplier);
}
return $this;
}
public function removeRuleDoesNotWorkWithSupplier(Supplier $supplier)
{
$this->ruleDoesNotWorkWithSuppliers->removeElement($supplier);
return $this;
}
/**
* @return ArrayCollection
*/
public function getMessageMatches()
{
return $this->messageMatches;
}
/**
* @param ArrayCollection $messageMatches
*
* @return Message
*/
public function setMessageMatches($messageMatches)
{
$this->messageMatches = $messageMatches;
return $this;
}
/**
* @param MessageMatch $messageMatch
*
* @return Message
*/
public function addMessageMatch($messageMatch)
{
$this->messageMatches->add($messageMatch);
return $this;
}
/**
* @param MessageMatch $messageMatch
*/
public function removeMessageMatch($messageMatch)
{
if (! $this->messageMatches->contains($messageMatch)) {
return $this;
}
$this->messageMatches->removeElement($messageMatch);
}
/**
* @return bool
*/
public function isEnabled()
{
return $this->enabled;
}
/**
* @param bool $enabled
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
}
/**
* @return mixed
*/
public function getExtraData()
{
return $this->extraData;
}
/**
* @param mixed $extraData
*/
public function setExtraData($extraData): void
{
$this->extraData = $extraData;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type): void
{
$this->type = $type;
}
/**
* @return string
*/
public function getColor()
{
return $this->color;
}
/**
* @param string $color
*/
public function setColor(string $color): void
{
$this->color = $color;
}
/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return Message
* @ORM\PrePersist()
* @throws Exception
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set updatedAt
*
* @return Message
* @ORM\PreUpdate
* @throws Exception
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
return $this;
}
/**
* @return bool
*/
public function isWithNotification(): bool
{
return $this->withNotification;
}
/**
* @param bool $withNotification
*/
public function setWithNotification(bool $withNotification): void
{
$this->withNotification = $withNotification;
}
}