src/Entity/Gos/TouchPoint.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\Request;
  5. /**
  6.  * @ORM\Entity(repositoryClass="App\Repository\TouchPointRepository")
  7.  * @ORM\HasLifecycleCallbacks
  8.  */
  9. class TouchPoint
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=8, nullable=true)
  19.      */
  20.     private $actionNumber;
  21.     /**
  22.      * @ORM\Column(type="string", length=100, nullable=true)
  23.      */
  24.     private $fromSource;
  25.     /**
  26.      * @ORM\Column(type="string", length=100, nullable=true)
  27.      */
  28.     private $campaign;
  29.     /**
  30.      * @ORM\Column(type="string", length=100, nullable=true)
  31.      */
  32.     private $campaignChannel;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $cookiesHash;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $visitorID;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $visitID;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $gosVisitID;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $customerID;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true)
  55.      */
  56.     private $touchPointType;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\User", inversedBy="touchPoint")
  59.      * @ORM\JoinColumn()
  60.      */
  61.     private $user;
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\PortalSettings", inversedBy="touchPoint")
  64.      * @ORM\JoinColumn()
  65.      */
  66.     private $portalSettings;
  67.     /**
  68.      * @ORM\OneToOne(targetEntity="App\Entity\Gos\Orders", inversedBy="touchPoint")
  69.      * @ORM\JoinColumn()
  70.      */
  71.     private $order;
  72.     /**
  73.      * @ORM\Column(type="datetime")
  74.      */
  75.     private $createdAt;
  76.     /**
  77.      * @ORM\Column(type="datetime", nullable=true)
  78.      */
  79.     private $updatedAt;
  80.     /**
  81.      * @ORM\Column(type="text", nullable=true)
  82.      */
  83.     private $url;
  84.     /**
  85.      * @ORM\Column(type="text", nullable=true)
  86.      */
  87.     private $userAgent;
  88.     /**
  89.      * @ORM\Column(type="text", nullable=true)
  90.      */
  91.     private $dataLayerUrl;
  92.     public function getObjectVars()
  93.     {
  94.         return get_object_vars($this);
  95.     }
  96.     public function generatedCookiesHash()
  97.     {
  98.         $this->cookiesHash bin2hex(random_bytes(15));
  99.         return $this;
  100.     }
  101.     public function generatedCustomerID(User $user)
  102.     {
  103.         $this->customerID md5($user->getEmail());
  104.         return $this;
  105.     }
  106.     public function generatedGosVisitID()
  107.     {
  108.         $this->gosVisitID bin2hex(random_bytes(15));
  109.         return $this;
  110.     }
  111.     public function setActionNumberFromPortalSettings()
  112.     {
  113.         if (!empty($this->getPortalSettings()))
  114.         {
  115.             $this->setActionNumber($this->getPortalSettings()->getActionNumber());
  116.         }
  117.         return $this;
  118.     }
  119.     public function setDataFromRequest(Request $request)
  120.     {
  121.         if (!empty($request->query->get('a')))
  122.         {
  123.             $this->setActionNumber($request->query->get('a'));
  124.         }
  125.         else
  126.         {
  127.             $this->setActionNumber($request->request->get('a'));
  128.         }
  129.         $this->setFromSource($request->query->get('f'));
  130.         $this->setCampaign($request->query->get('c'));
  131.         $this->setCampaignChannel($request->query->get('chc'));
  132.         $this->setVisitID($request->query->get('visitId'));
  133.         $this->setVisitorID($request->query->get('visitorId'));
  134.         $this->setDataLayerUrl($request->query->get('dataLayerUrl'));
  135.         $this->setUserAgent($request->server->get('HTTP_USER_AGENT'));
  136.     }
  137.     /** @ORM\PrePersist() */
  138.     public function prePersist()
  139.     {
  140.         $this->createdAt = new \DateTime();
  141.     }
  142.     /** @ORM\PreUpdate() */
  143.     public function preUpdate()
  144.     {
  145.         $this->updatedAt = new \DateTime();
  146.     }
  147.     public function __toString()
  148.     {
  149.         return (string)$this->cookiesHash;
  150.     }
  151.     //------------------------------ setters & getters
  152.     public function getId(): ?int
  153.     {
  154.         return $this->id;
  155.     }
  156.     public function getActionNumber(): ?string
  157.     {
  158.         return $this->actionNumber;
  159.     }
  160.     public function setActionNumber(?string $actionNumber): self
  161.     {
  162.         $this->actionNumber $actionNumber;
  163.         return $this;
  164.     }
  165.     public function getFromSource(): ?string
  166.     {
  167.         return $this->fromSource;
  168.     }
  169.     public function setFromSource(?string $fromSource): self
  170.     {
  171.         $this->fromSource $fromSource;
  172.         return $this;
  173.     }
  174.     public function getCampaign(): ?string
  175.     {
  176.         return $this->campaign;
  177.     }
  178.     public function setCampaign(?string $campaign): self
  179.     {
  180.         $this->campaign $campaign;
  181.         return $this;
  182.     }
  183.     public function getCampaignChannel(): ?string
  184.     {
  185.         return $this->campaignChannel;
  186.     }
  187.     public function setCampaignChannel(?string $campaignChannel): self
  188.     {
  189.         $this->campaignChannel $campaignChannel;
  190.         return $this;
  191.     }
  192.     public function getCookiesHash(): ?string
  193.     {
  194.         return $this->cookiesHash;
  195.     }
  196.     public function setCookiesHash(?string $cookiesHash): self
  197.     {
  198.         $this->cookiesHash $cookiesHash;
  199.         return $this;
  200.     }
  201.     public function getVisitorID(): ?string
  202.     {
  203.         return $this->visitorID;
  204.     }
  205.     public function setVisitorID(?string $visitorID): self
  206.     {
  207.         $this->visitorID $visitorID;
  208.         return $this;
  209.     }
  210.     public function getVisitID(): ?string
  211.     {
  212.         return $this->visitID;
  213.     }
  214.     public function setVisitID(?string $visitID): self
  215.     {
  216.         $this->visitID $visitID;
  217.         return $this;
  218.     }
  219.     public function getGosVisitID(): ?string
  220.     {
  221.         return $this->gosVisitID;
  222.     }
  223.     public function setGosVisitID(?string $gosVisitID): self
  224.     {
  225.         $this->gosVisitID $gosVisitID;
  226.         return $this;
  227.     }
  228.     public function getCustomerID(): ?string
  229.     {
  230.         return $this->customerID;
  231.     }
  232.     public function setCustomerID(?string $customerID): self
  233.     {
  234.         $this->customerID $customerID;
  235.         return $this;
  236.     }
  237.     public function getCreatedAt(): ?\DateTimeInterface
  238.     {
  239.         return $this->createdAt;
  240.     }
  241.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  242.     {
  243.         $this->createdAt $createdAt;
  244.         return $this;
  245.     }
  246.     public function getUpdatedAt(): ?\DateTimeInterface
  247.     {
  248.         return $this->updatedAt;
  249.     }
  250.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  251.     {
  252.         $this->updatedAt $updatedAt;
  253.         return $this;
  254.     }
  255.     public function getUser(): ?User
  256.     {
  257.         return $this->user;
  258.     }
  259.     public function setUser(?User $user): self
  260.     {
  261.         $this->user $user;
  262.         return $this;
  263.     }
  264.     public function getPortalSettings(): ?PortalSettings
  265.     {
  266.         return $this->portalSettings;
  267.     }
  268.     public function setPortalSettings(?PortalSettings $portalSettings): self
  269.     {
  270.         $this->portalSettings $portalSettings;
  271.         return $this;
  272.     }
  273.     public function getTouchPointType(): ?string
  274.     {
  275.         return $this->touchPointType;
  276.     }
  277.     public function setTouchPointType(?string $touchPointType): self
  278.     {
  279.         $this->touchPointType $touchPointType;
  280.         return $this;
  281.     }
  282.     public function getOrder(): ?Orders
  283.     {
  284.         return $this->order;
  285.     }
  286.     public function setOrder(?Orders $order): self
  287.     {
  288.         $this->order $order;
  289.         return $this;
  290.     }
  291.     public function getUrl(): ?string
  292.     {
  293.         return $this->url;
  294.     }
  295.     public function setUrl(?string $url): self
  296.     {
  297.         $this->url $url;
  298.         return $this;
  299.     }
  300.     public function getDataLayerUrl(): ?string
  301.     {
  302.         return $this->dataLayerUrl;
  303.     }
  304.     public function setDataLayerUrl(?string $dataLayerUrl): self
  305.     {
  306.         $this->dataLayerUrl $dataLayerUrl;
  307.         return $this;
  308.     }
  309.     public function getUserAgent(): ?string
  310.     {
  311.         return $this->userAgent;
  312.     }
  313.     public function setUserAgent(?string $userAgent): self
  314.     {
  315.         $this->userAgent $userAgent;
  316.         return $this;
  317.     }
  318. }