Completed
Push — master ( d28136...3a5b5f )
by Julito
16:58
created

AccessUrl::getResourceFieldName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nop 0
dl 0
loc 3
rs 10
nc 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Entity;
5
6
use Chamilo\CoreBundle\Entity\Resource\AbstractResource;
7
use Chamilo\CoreBundle\Entity\Resource\ResourceInterface;
8
use Chamilo\CoreBundle\Traits\CourseTrait;
9
use Doctrine\ORM\Mapping as ORM;
10
11
/**
12
 * AccessUrl.
13
 *
14
 * @ORM\Table(name="access_url")
15
 * @ORM\Entity
16
 */
17
class AccessUrl extends AbstractResource implements ResourceInterface
18
{
19
    use CourseTrait;
20
21
    /**
22
     * @var int
23
     *
24
     * @ORM\Column(name="id", type="integer")
25
     * @ORM\Id
26
     * @ORM\GeneratedValue(strategy="AUTO")
27
     */
28
    protected $id;
29
30
    /**
31
     * @ORM\OneToMany(targetEntity="AccessUrlRelCourse", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
32
     */
33
    protected $course;
34
35
    /**
36
     * @ORM\OneToMany(targetEntity="AccessUrlRelSession", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
37
     */
38
    protected $session;
39
40
    /**
41
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SettingsCurrent", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
42
     */
43
    protected $settings;
44
45
    /**
46
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionCategory", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
47
     */
48
    protected $sessionCategory;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(name="url", type="string", length=255, nullable=false, unique=false)
54
     */
55
    protected $url;
56
57
    /**
58
     * @var string
59
     *
60
     * @ORM\Column(name="description", type="text", unique=false)
61
     */
62
    protected $description;
63
64
    /**
65
     * @var int
66
     *
67
     * @ORM\Column(name="active", type="integer", nullable=false, unique=false)
68
     */
69
    protected $active;
70
71
    /**
72
     * @var int
73
     *
74
     * @ORM\Column(name="created_by", type="integer", nullable=false, unique=false)
75
     */
76
    protected $createdBy;
77
78
    /**
79
     * @var \DateTime
80
     *
81
     * @ORM\Column(name="tms", type="datetime", nullable=true)
82
     */
83
    protected $tms;
84
85
    /**
86
     * @var bool
87
     *
88
     * @ORM\Column(name="url_type", type="boolean", nullable=true)
89
     */
90
    protected $urlType;
91
92
    /**
93
     * @var int
94
     *
95
     * @ORM\Column(name="limit_courses", type="integer", nullable=true, unique=false)
96
     */
97
    protected $limitCourses;
98
99
    /**
100
     * @var int
101
     *
102
     * @ORM\Column(name="limit_active_courses", type="integer", nullable=true, unique=false)
103
     */
104
    protected $limitActiveCourses;
105
106
    /**
107
     * @var int
108
     *
109
     * @ORM\Column(name="limit_sessions", type="integer", nullable=true, unique=false)
110
     */
111
    protected $limitSessions;
112
113
    /**
114
     * @var int
115
     *
116
     * @ORM\Column(name="limit_users", type="integer", nullable=true, unique=false)
117
     */
118
    protected $limitUsers;
119
120
    /**
121
     * @var int
122
     *
123
     * @ORM\Column(name="limit_teachers", type="integer", nullable=true, unique=false)
124
     */
125
    protected $limitTeachers;
126
127
    /**
128
     * @var int
129
     *
130
     * @ORM\Column(name="limit_disk_space", type="integer", nullable=true, unique=false)
131
     */
132
    protected $limitDiskSpace;
133
134
    /**
135
     * @var string
136
     *
137
     * @ORM\Column(name="email", type="string", length=255, nullable=true, unique=false)
138
     */
139
    protected $email;
140
141
    /**
142
     * Constructor.
143
     */
144
    public function __construct()
145
    {
146
        $this->tms = new \DateTime();
147
        $this->createdBy = 1;
148
    }
149
150
    /**
151
     * @return string
152
     */
153
    public function __toString(): string
154
    {
155
        return (string) $this->getUrl();
156
    }
157
158
    /**
159
     * Get id.
160
     *
161
     * @return int
162
     */
163
    public function getId()
164
    {
165
        return $this->id;
166
    }
167
168
    /**
169
     * Set url.
170
     *
171
     * @param string $url
172
     *
173
     * @return AccessUrl
174
     */
175
    public function setUrl($url)
176
    {
177
        $this->url = $url;
178
179
        return $this;
180
    }
181
182
    /**
183
     * Get url.
184
     *
185
     * @return string
186
     */
187
    public function getUrl()
188
    {
189
        return $this->url;
190
    }
191
192
    /**
193
     * Set description.
194
     *
195
     * @param string $description
196
     *
197
     * @return AccessUrl
198
     */
199
    public function setDescription($description)
200
    {
201
        $this->description = $description;
202
203
        return $this;
204
    }
205
206
    /**
207
     * Get description.
208
     *
209
     * @return string
210
     */
211
    public function getDescription()
212
    {
213
        return $this->description;
214
    }
215
216
    /**
217
     * Set active.
218
     *
219
     * @param int $active
220
     *
221
     * @return AccessUrl
222
     */
223
    public function setActive($active)
224
    {
225
        $this->active = $active;
226
227
        return $this;
228
    }
229
230
    /**
231
     * Get active.
232
     *
233
     * @return int
234
     */
235
    public function getActive()
236
    {
237
        return $this->active;
238
    }
239
240
    /**
241
     * Set createdBy.
242
     *
243
     * @param int $createdBy
244
     *
245
     * @return AccessUrl
246
     */
247
    public function setCreatedBy($createdBy)
248
    {
249
        $this->createdBy = $createdBy;
250
251
        return $this;
252
    }
253
254
    /**
255
     * Get createdBy.
256
     *
257
     * @return int
258
     */
259
    public function getCreatedBy()
260
    {
261
        return $this->createdBy;
262
    }
263
264
    /**
265
     * Set tms.
266
     *
267
     * @param \DateTime $tms
268
     *
269
     * @return AccessUrl
270
     */
271
    public function setTms($tms)
272
    {
273
        $this->tms = $tms;
274
275
        return $this;
276
    }
277
278
    /**
279
     * Get tms.
280
     *
281
     * @return \DateTime
282
     */
283
    public function getTms()
284
    {
285
        return $this->tms;
286
    }
287
288
    /**
289
     * Set urlType.
290
     *
291
     * @param bool $urlType
292
     *
293
     * @return AccessUrl
294
     */
295
    public function setUrlType($urlType)
296
    {
297
        $this->urlType = $urlType;
298
299
        return $this;
300
    }
301
302
    /**
303
     * Get urlType.
304
     *
305
     * @return bool
306
     */
307
    public function getUrlType()
308
    {
309
        return $this->urlType;
310
    }
311
312
    /**
313
     * @return int
314
     */
315
    public function getLimitActiveCourses()
316
    {
317
        return $this->limitActiveCourses;
318
    }
319
320
    /**
321
     * @param int $limitActiveCourses
322
     *
323
     * @return AccessUrl
324
     */
325
    public function setLimitActiveCourses($limitActiveCourses)
326
    {
327
        $this->limitActiveCourses = $limitActiveCourses;
328
329
        return $this;
330
    }
331
332
    /**
333
     * @return int
334
     */
335
    public function getLimitSessions()
336
    {
337
        return $this->limitSessions;
338
    }
339
340
    /**
341
     * @param int $limitSessions
342
     *
343
     * @return AccessUrl
344
     */
345
    public function setLimitSessions($limitSessions)
346
    {
347
        $this->limitSessions = $limitSessions;
348
349
        return $this;
350
    }
351
352
    /**
353
     * @return int
354
     */
355
    public function getLimitUsers()
356
    {
357
        return $this->limitUsers;
358
    }
359
360
    /**
361
     * @param int $limitUsers
362
     *
363
     * @return AccessUrl
364
     */
365
    public function setLimitUsers($limitUsers)
366
    {
367
        $this->limitUsers = $limitUsers;
368
369
        return $this;
370
    }
371
372
    /**
373
     * @return int
374
     */
375
    public function getLimitTeachers()
376
    {
377
        return $this->limitTeachers;
378
    }
379
380
    /**
381
     * @param int $limitTeachers
382
     *
383
     * @return AccessUrl
384
     */
385
    public function setLimitTeachers($limitTeachers)
386
    {
387
        $this->limitTeachers = $limitTeachers;
388
389
        return $this;
390
    }
391
392
    /**
393
     * @return int
394
     */
395
    public function getLimitDiskSpace()
396
    {
397
        return $this->limitDiskSpace;
398
    }
399
400
    /**
401
     * @param int $limitDiskSpace
402
     *
403
     * @return AccessUrl
404
     */
405
    public function setLimitDiskSpace($limitDiskSpace)
406
    {
407
        $this->limitDiskSpace = $limitDiskSpace;
408
409
        return $this;
410
    }
411
412
    /**
413
     * @return string
414
     */
415
    public function getEmail()
416
    {
417
        return $this->email;
418
    }
419
420
    /**
421
     * @param string $email
422
     *
423
     * @return AccessUrl
424
     */
425
    public function setEmail($email)
426
    {
427
        $this->email = $email;
428
429
        return $this;
430
    }
431
432
    /**
433
     * @return mixed
434
     */
435
    public function getSettings()
436
    {
437
        return $this->settings;
438
    }
439
440
    /**
441
     * @param mixed $settings
442
     *
443
     * @return AccessUrl
444
     */
445
    public function setSettings($settings)
446
    {
447
        $this->settings = $settings;
448
449
        return $this;
450
    }
451
452
    /**
453
     * @return mixed
454
     */
455
    public function getSessionCategory()
456
    {
457
        return $this->sessionCategory;
458
    }
459
460
    /**
461
     * @param mixed $sessionCategory
462
     *
463
     * @return AccessUrl
464
     */
465
    public function setSessionCategory($sessionCategory)
466
    {
467
        $this->sessionCategory = $sessionCategory;
468
469
        return $this;
470
    }
471
472
    /**
473
     * @return int
474
     */
475
    public function getLimitCourses()
476
    {
477
        return $this->limitCourses;
478
    }
479
480
    /**
481
     * @param int $limitCourses
482
     *
483
     * @return AccessUrl
484
     */
485
    public function setLimitCourses($limitCourses)
486
    {
487
        $this->limitCourses = $limitCourses;
488
489
        return $this;
490
    }
491
492
    /**
493
     * Resource identifier.
494
     */
495
    public function getResourceIdentifier(): int
496
    {
497
        return $this->getId();
498
    }
499
500
    public function getResourceName(): string
501
    {
502
        $url = $this->getUrl();
503
        $url = parse_url($url);
504
505
        $url = $url['host'];
506
507
        return $url;
508
    }
509
}
510