-
Notifications
You must be signed in to change notification settings - Fork 454
/
CalendarEventVersionOccurrence.php
97 lines (80 loc) · 2.3 KB
/
CalendarEventVersionOccurrence.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Concrete\Core\Entity\Calendar;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="CalendarEventVersionOccurrences")
*/
class CalendarEventVersionOccurrence
{
/**
* @ORM\Id @ORM\Column(type="integer", options={"unsigned": true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $versionOccurrenceID;
/**
* @ORM\ManyToOne(targetEntity="CalendarEventVersion", inversedBy="occurrences")
* @ORM\JoinColumn(name="eventVersionID", referencedColumnName="eventVersionID")
*/
protected $version;
/**
* @ORM\ManyToOne(targetEntity="CalendarEventOccurrence", cascade={"persist"})
* @ORM\JoinColumn(name="occurrenceID", referencedColumnName="occurrenceID")
*/
protected $occurrence;
public function getJSONObject()
{
$ev = $this->getEvent();
$r = array();
$r['start'] = $this->occurrence->getStart();
$r['end'] = $this->occurrence->getEnd();
return (object) array_merge($r, (array) $ev->getJSONObject());
}
public function __construct(CalendarEventVersion $version, CalendarEventRepetition $repetition, $start, $end, $cancelled = false)
{
$this->version = $version;
$this->occurrence = new CalendarEventOccurrence($repetition, $start, $end, $cancelled);
}
public function getEvent()
{
return $this->version->getEvent();
}
/**
* @return mixed
*/
public function getVersion()
{
return $this->version;
}
/**
* @param mixed $version
*/
public function setVersion($version)
{
$this->version = $version;
}
/**
* @return CalendarEventOccurrence
*/
public function getOccurrence()
{
return $this->occurrence;
}
public function __clone()
{
if ($this->versionOccurrenceID) {
$this->versionOccurrenceID = null;
}
}
public function getID()
{
return $this->versionOccurrenceID;
}
public function __call($name, $arguments)
{
if (!method_exists($this->occurrence, $name)) {
throw new \RuntimeException(t('Method %s does not exist for CalendarEventOccurrence class.', $name));
}
return call_user_func_array([$this->occurrence, $name], $arguments);
}
}