zend-blog-3-backend

Форк
0
/
TrackingAgent.php 
202 строки · 3.4 Кб
1
<?php
2

3
namespace App\Entity;
4

5
use DateTime;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\Common\Collections\Collection;
8
use Doctrine\ORM\Mapping as ORM;
9

10
/**
11
 * @ORM\Table(name="tracking_agent")
12
 * @ORM\Entity(repositoryClass="App\Repository\TrackingAgentRepository")
13
 */
14
class TrackingAgent
15
{
16
    /**
17
     * @var int
18
     *
19
     * @ORM\Id
20
     * @ORM\Column(type="integer")
21
     * @ORM\GeneratedValue(strategy="AUTO")
22
     */
23
    protected $id;
24

25
    /**
26
     * @var string
27
     *
28
     * @ORM\Column(type="text", length=65000)
29
     */
30
    protected $userAgent;
31

32
    /**
33
     * @var string
34
     *
35
     * @ORM\Column(type="string", length=32, unique=true)
36
     */
37
    protected $hash;
38

39
    /**
40
     * @var bool
41
     *
42
     * @ORM\Column(type="boolean", name="is_bot", options={"default": false})
43
     */
44
    protected $bot = false;
45

46
    /**
47
     * @var DateTime
48
     *
49
     * @ORM\Column(type="milliseconds_dt", options={"default": "CURRENT_TIMESTAMP(3)"})
50
     */
51
    protected $createdAt;
52

53
    /**
54
     * @var Collection
55
     *
56
     * @ORM\OneToMany(targetEntity="Tracking", mappedBy="trackingAgent", cascade={"persist"})
57
     */
58
    protected $trackings;
59

60
    public function __construct()
61
    {
62
        $this->trackings = new ArrayCollection();
63
        $this->createdAt = new DateTime();
64
    }
65

66
    /**
67
     * Get id
68
     *
69
     * @return int
70
     */
71
    public function getId()
72
    {
73
        return $this->id;
74
    }
75

76
    /**
77
     * Set userAgent
78
     *
79
     * @param string $userAgent
80
     *
81
     * @return TrackingAgent
82
     */
83
    public function setUserAgent($userAgent)
84
    {
85
        $this->userAgent = $userAgent;
86
        $this->hash = md5($userAgent);
87

88
        return $this;
89
    }
90

91
    /**
92
     * Get userAgent
93
     *
94
     * @return string
95
     */
96
    public function getUserAgent()
97
    {
98
        return $this->userAgent;
99
    }
100

101
    /**
102
     * Add trackings
103
     *
104
     * @param Tracking $trackings
105
     *
106
     * @return TrackingAgent
107
     */
108
    public function addTracking(Tracking $trackings)
109
    {
110
        $this->trackings[] = $trackings;
111

112
        return $this;
113
    }
114

115
    /**
116
     * Remove trackings
117
     *
118
     * @param Tracking $trackings
119
     */
120
    public function removeTracking(Tracking $trackings)
121
    {
122
        $this->trackings->removeElement($trackings);
123
    }
124

125
    /**
126
     * Get trackings
127
     *
128
     * @return Collection
129
     */
130
    public function getTrackings()
131
    {
132
        return $this->trackings;
133
    }
134

135
    /**
136
     * Set hash
137
     *
138
     * @param string $hash
139
     *
140
     * @return TrackingAgent
141
     */
142
    public function setHash($hash)
143
    {
144
        $this->hash = $hash;
145

146
        return $this;
147
    }
148

149
    /**
150
     * Get hash
151
     *
152
     * @return string
153
     */
154
    public function getHash()
155
    {
156
        return $this->hash;
157
    }
158

159
    /**
160
     * Set createdAt
161
     *
162
     * @param DateTime $createdAt
163
     *
164
     * @return TrackingAgent
165
     */
166
    public function setCreatedAt($createdAt)
167
    {
168
        $this->createdAt = $createdAt;
169

170
        return $this;
171
    }
172

173
    /**
174
     * Get createdAt
175
     *
176
     * @return DateTime
177
     */
178
    public function getCreatedAt(): DateTime
179
    {
180
        return $this->createdAt;
181
    }
182

183
    /**
184
     * @return bool
185
     */
186
    public function isBot(): bool
187
    {
188
        return $this->bot;
189
    }
190

191
    /**
192
     * @param bool $bot
193
     *
194
     * @return $this
195
     */
196
    public function setBot(bool $bot): self
197
    {
198
        $this->bot = $bot;
199

200
        return $this;
201
    }
202
}
203

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.