src/Entity/CustomerHistoryEntry.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Person;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Menke\CommonsBundle\Entity\GenericEntity;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\CustomerHistoryEntryRepository")
  8.  * @ORM\HasLifecycleCallbacks
  9.  */
  10. class CustomerHistoryEntry
  11. {
  12.     const TYPE_SYSTEM_EVENT 'system_event';
  13.     const TYPE_EMAIL 'email';
  14.     const TYPE_NEWSLETTER_REGISTER 'nl_register';
  15.     const TYPE_NEWSLETTER_DEREGISTER 'nl_deregister';
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     protected $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     protected $entry;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity="App\Entity\Person", inversedBy="history")
  28.      */
  29.     protected $customer;
  30.     /**
  31.      * @ORM\Column(type="string", length=50)
  32.      */
  33.     protected $systemAgent;
  34.     /**
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     protected $date;
  38.     /**
  39.      * @ORM\Column(type="string", length=50)
  40.      */
  41.     protected $type self::TYPE_SYSTEM_EVENT;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity="App\Entity\EmailHistoryEntry")
  44.      */
  45.     protected $emailHistoryEntry;
  46.     /**
  47.      * @ORM\Column(type="integer", nullable=true)
  48.      */
  49.     private $admin_id;
  50.     /**
  51.      * @ORM\Column(type="boolean", nullable=true)
  52.      */
  53.     private $set_by_admin;
  54.     /**
  55.      * @ORM\OneToOne(targetEntity=ManualNewsletter::class, cascade={"persist", "remove"})
  56.      */
  57.     private $manual_newsletter;
  58.     /**
  59.      * @param string $entry
  60.      * @param Person $customer
  61.      * @param string $systemAgent
  62.      */
  63.     public function __construct($entry nullPerson $customer null$systemAgent null)
  64.     {
  65.         $this->entry $entry;
  66.         $this->customer $customer;
  67.         $this->systemAgent $systemAgent;
  68.         $this->date = new \Datetime();
  69.     }
  70.     /**
  71.      * Create prefilled history entry for newsletter registration
  72.      *
  73.      * @param Person $customer
  74.      * @param string $systemAgent
  75.      * @return CustomerHistoryEntry
  76.      */
  77.     public static function createForNewsletterRegister(Person $customer$systemAgent)
  78.     {
  79.         $entry = new CustomerHistoryEntry('Newsletter abonniert'$customer$systemAgent);
  80.         $entry->setType(CustomerHistoryEntry::TYPE_NEWSLETTER_REGISTER);
  81.         return $entry;
  82.     }
  83.     /**
  84.      * Create prefilled history entry for newsletter deregistration
  85.      *
  86.      * @param Person $customer
  87.      * @param string $systemAgent
  88.      * @return CustomerHistoryEntry
  89.      */
  90.     public static function createForNewsletterDeregister(Person $customer$systemAgent)
  91.     {
  92.         $entry = new CustomerHistoryEntry('Newsletter abbestellt'$customer$systemAgent);
  93.         $entry->setType(CustomerHistoryEntry::TYPE_NEWSLETTER_DEREGISTER);
  94.         return $entry;
  95.     }
  96.     /**
  97.      * Create prefilled history entry for privacy policy acceptance registration
  98.      *
  99.      * @param Person $customer
  100.      * @param string $systemAgent
  101.      * @return CustomerHistoryEntry
  102.      */
  103.     public static function createForPrivacyPolicyConfirm(Person $customer$systemAgent)
  104.     {
  105.         $entry = new CustomerHistoryEntry('Datenschutz zugestimmt'$customer$systemAgent);
  106.         return $entry;
  107.     }
  108.     /**
  109.      * Create prefilled history entry for privacy policy acceptance deregistration
  110.      *
  111.      * @param Person $customer
  112.      * @param string $systemAgent
  113.      * @return CustomerHistoryEntry
  114.      */
  115.     public static function createForPrivacyPolicyDeconfirm(Person $customer$systemAgent)
  116.     {
  117.         $entry = new CustomerHistoryEntry('Datenschutz Zustimmung zurückgezogen'$customer$systemAgent);
  118.         return $entry;
  119.     }
  120.     /**
  121.      * @return int|null
  122.      */
  123.     public function getId(): ?int
  124.     {
  125.         return $this->id;
  126.     }
  127.     /**
  128.      * @return null|string
  129.      */
  130.     public function getEntry(): ?string
  131.     {
  132.         return $this->entry;
  133.     }
  134.     /**
  135.      * @param string $entry
  136.      * @return CustomerHistoryEntry
  137.      */
  138.     public function setEntry(string $entry): self
  139.     {
  140.         $this->entry $entry;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return Person|null
  145.      */
  146.     public function getCustomer(): ?Person
  147.     {
  148.         return $this->customer;
  149.     }
  150.     /**
  151.      * @param Person|null $customer
  152.      * @return CustomerHistoryEntry
  153.      */
  154.     public function setCustomer(?Person $customer): self
  155.     {
  156.         $this->customer $customer;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return null|string
  161.      */
  162.     public function getSystemAgent(): ?string
  163.     {
  164.         return $this->systemAgent;
  165.     }
  166.     /**
  167.      * @param string $systemAgent
  168.      * @return CustomerHistoryEntry
  169.      */
  170.     public function setSystemAgent(string $systemAgent): self
  171.     {
  172.         $this->systemAgent $systemAgent;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return \DateTimeInterface|null
  177.      */
  178.     public function getDate(): ?\DateTimeInterface
  179.     {
  180.         return $this->date;
  181.     }
  182.     /**
  183.      * @param \DateTimeInterface $date
  184.      * @return CustomerHistoryEntry
  185.      */
  186.     public function setDate(\DateTimeInterface $date): self
  187.     {
  188.         $this->date $date;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return string|null
  193.      */
  194.     public function getType(): ?string
  195.     {
  196.         return $this->type;
  197.     }
  198.     /**
  199.      * @param string $type
  200.      * @return self
  201.      */
  202.     public function setType(string $type): self
  203.     {
  204.         $this->type $type;
  205.         return $this;
  206.     }
  207.     /**
  208.      * @return EmailHistoryEntry|null
  209.      */
  210.     public function getEmailHistoryEntry(): ?EmailHistoryEntry
  211.     {
  212.         return $this->emailHistoryEntry;
  213.     }
  214.     /**
  215.      * @param EmailHistoryEntry|null $emailHistoryEntry
  216.      * @return self
  217.      */
  218.     public function setEmailHistoryEntry(?EmailHistoryEntry $emailHistoryEntry): self
  219.     {
  220.         $this->emailHistoryEntry $emailHistoryEntry;
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return boolean
  225.      */
  226.     public function isNewsletterRegister()
  227.     {
  228.         return $this->type == self::TYPE_NEWSLETTER_REGISTER;
  229.     }
  230.     /**
  231.      * @return boolean
  232.      */
  233.     public function isNewsletterDeregister()
  234.     {
  235.         return $this->type == self::TYPE_NEWSLETTER_DEREGISTER;
  236.     }
  237.     /**
  238.      * @ORM\PostPersist
  239.      */
  240.     public function onPostPersist()
  241.     {
  242.         $this->date = new \DateTime();
  243.     }
  244.     public function getAdminId(): ?int
  245.     {
  246.         return $this->admin_id;
  247.     }
  248.     public function setAdminId(?int $admin_id): self
  249.     {
  250.         $this->admin_id $admin_id;
  251.         return $this;
  252.     }
  253.     public function getSetByAdmin(): ?bool
  254.     {
  255.         return $this->set_by_admin;
  256.     }
  257.     public function setSetByAdmin(?bool $set_by_admin): self
  258.     {
  259.         $this->set_by_admin $set_by_admin;
  260.         return $this;
  261.     }
  262.     public function getManualNewsletter(): ?ManualNewsletter
  263.     {
  264.         return $this->manual_newsletter;
  265.     }
  266.     public function setManualNewsletter(?ManualNewsletter $manual_newsletter): self
  267.     {
  268.         $this->manual_newsletter $manual_newsletter;
  269.         return $this;
  270.     }
  271. }