1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Edofre\Fullcalendar; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Event |
7
|
|
|
* @package Edofre\Fullcalendar |
8
|
|
|
*/ |
9
|
|
|
class Event |
10
|
|
|
{ |
11
|
|
|
/** Rendering options */ |
12
|
|
|
const RENDERING_BACKGROUND = 'background'; |
13
|
|
|
const RENDERING_INVERSE_BACKGROUND = 'inverse-background'; |
14
|
|
|
|
15
|
|
|
/** @var string Uniquely identifies the given event. Different instances of repeating events should all have the same id. */ |
16
|
|
|
public $id; |
17
|
|
|
/** @var string The text on an event's element */ |
18
|
|
|
public $title; |
19
|
|
|
/** @var boolean Whether an event occurs at a specific time-of-day. This property affects whether an event's time is shown. Also, in the agenda views, determines if it is displayed in the "all-day" section. */ |
20
|
|
|
public $allDay = false; |
21
|
|
|
/** @var string The date/time an event begins. A Moment-ish input, like an ISO8601 string. Throughout the API this will become a real Moment object. */ |
22
|
|
|
public $start; |
23
|
|
|
/** @var string The exclusive date/time an event ends. A Moment-ish input, like an ISO8601 string. Throughout the API this will become a real Moment object. */ |
24
|
|
|
public $end; |
25
|
|
|
/** @var string A URL that will be visited when this event is clicked by the user. For more information on controlling this behavior, see the eventClick callback. */ |
26
|
|
|
public $url; |
27
|
|
|
/** @var string|array A CSS class ( or array of classes) that will be attached to this event's element. */ |
28
|
|
|
public $className; |
29
|
|
|
/** @var boolean Is the Event editable? Both start and duration. */ |
30
|
|
|
public $editable = false; |
31
|
|
|
/** @var boolean Is the event start editable? */ |
32
|
|
|
public $startEditable = false; |
33
|
|
|
/** @var boolean Is the event duration editable? */ |
34
|
|
|
public $durationEditable = false; |
35
|
|
|
/** @var string Allows alternate rendering of the event, like background events. Can be empty, "background", or "inverse-background" */ |
36
|
|
|
public $rendering; |
37
|
|
|
/** @var boolean Overrides the master eventOverlap option for this single event. If false, prevents this event from being dragged/resized over other events. Also prevents other events from being dragged/resized over this event. */ |
38
|
|
|
public $overlap = true; |
39
|
|
|
/** @var string an event ID, "businessHours", object. Optional. Overrides the master eventConstraint option for this single event. */ |
40
|
|
|
public $constraint; |
41
|
|
|
/** @var string Event Source Object. Automatically populated. A reference to the event source that this event came from. */ |
42
|
|
|
public $source; |
43
|
|
|
/** @var string Sets an event's background and border color just like the calendar-wide eventColor option. */ |
44
|
|
|
public $color; |
45
|
|
|
/** @var string Sets an event's background color just like the calendar-wide eventBackgroundColor option. */ |
46
|
|
|
public $backgroundColor; |
47
|
|
|
/** @var string Sets an event's border color just like the the calendar-wide eventBorderColor option. */ |
48
|
|
|
public $borderColor; |
49
|
|
|
/** @var string Sets an event's text color just like the calendar-wide eventTextColor option. */ |
50
|
|
|
public $textColor; |
51
|
|
|
|
52
|
|
|
/** @var array Validation rules */ |
53
|
|
|
public $rules = [ |
54
|
|
|
'id' => '', |
55
|
|
|
'title' => 'required', |
56
|
|
|
'allDay' => '', |
57
|
|
|
'start' => 'required', |
58
|
|
|
'end' => '', |
59
|
|
|
'url' => '', |
60
|
|
|
'className' => '', |
61
|
|
|
'editable' => 'boolean', |
62
|
|
|
'startEditable' => 'boolean', |
63
|
|
|
'durationEditable' => 'boolean', |
64
|
|
|
'rendering' => '', |
65
|
|
|
'overlap' => 'boolean', |
66
|
|
|
'constraint' => '', |
67
|
|
|
'source' => '', |
68
|
|
|
'color' => '', |
69
|
|
|
'backgroundColor' => '', |
70
|
|
|
'borderColor' => '', |
71
|
|
|
'textColor' => '', |
72
|
|
|
]; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Event constructor. |
76
|
|
|
* @param $args |
77
|
|
|
*/ |
78
|
|
|
function __construct($args) |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
foreach ($args as $key => $value) { |
81
|
|
|
$this->$key = $value; |
82
|
|
|
|
83
|
|
|
// if we have start and end date keys we need to convert them |
84
|
|
|
if (in_array($key, ['start', 'end'])) { |
85
|
|
|
$this->$key = !is_null($value) ? $value->toIso8601String() : null; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.