-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRecurringDate.php
64 lines (58 loc) · 1.35 KB
/
RecurringDate.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
<?php namespace ProcessWire;
use DateTime;
use RRule\RRule;
/**
* RecurringDate
*
* Contains the ocurrances, rrule data as json.
*
* @property OccurrenceArray $occurences
* @property RRule $rrule RRule in JSON format;
* @property bool $formatted
*
*/
class RecurringDate extends WireData
{
/**
* Construct a new Event
*s
*/
public function __construct()
{
// define the fields that represent our event (and their default/blank values)
$this->set('occurrences', new OccurrenceArray());
$this->set('settings', new RecurringDateSettings());
$this->set('rrule', null);
$this->set('pagination', []);
parent::__construct();
}
/**
* Set a value to the event: date, location or notes
*
* @param string $key
* @param string $value
* @return WireData|self
*
*/
public function set($key, $value)
{
if ($key == "settings" && is_array($value)) {
foreach($value as $key){
return $this->settings->set($key, $value);
}
} else {
return parent::set($key, $value);
}
return $this;
}
/**
* Return a string representing this event
*
* @return string
*
*/
public function __toString()
{
return (string) $this->occurrences;
}
}