Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97512094
PhabricatorCalendarICSWriter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 4, 19:10
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 6, 19:10 (2 d)
Engine
blob
Format
Raw Data
Handle
23419515
Attached To
rPH Phabricator
PhabricatorCalendarICSWriter.php
View Options
<?php
final
class
PhabricatorCalendarICSWriter
extends
Phobject
{
private
$viewer
;
private
$events
=
array
();
public
function
setViewer
(
PhabricatorUser
$viewer
)
{
$this
->
viewer
=
$viewer
;
return
$this
;
}
public
function
getViewer
()
{
return
$this
->
viewer
;
}
public
function
setEvents
(
array
$events
)
{
assert_instances_of
(
$events
,
'PhabricatorCalendarEvent'
);
$this
->
events
=
$events
;
return
$this
;
}
public
function
getEvents
()
{
return
$this
->
events
;
}
public
function
writeICSDocument
()
{
$viewer
=
$this
->
getViewer
();
$events
=
$this
->
getEvents
();
$events
=
mpull
(
$events
,
null
,
'getPHID'
);
if
(
$events
)
{
$child_map
=
id
(
new
PhabricatorCalendarEventQuery
())
->
setViewer
(
$viewer
)
->
withParentEventPHIDs
(
array_keys
(
$events
))
->
execute
();
$child_map
=
mpull
(
$child_map
,
null
,
'getPHID'
);
}
else
{
$child_map
=
array
();
}
$all_events
=
$events
+
$child_map
;
$child_groups
=
mgroup
(
$child_map
,
'getInstanceOfEventPHID'
);
$document_node
=
new
PhutilCalendarDocumentNode
();
foreach
(
$all_events
as
$event
)
{
$child_events
=
idx
(
$child_groups
,
$event
->
getPHID
(),
array
());
$event_node
=
$event
->
newIntermediateEventNode
(
$viewer
,
$child_events
);
$document_node
->
appendChild
(
$event_node
);
}
$root_node
=
id
(
new
PhutilCalendarRootNode
())
->
appendChild
(
$document_node
);
return
id
(
new
PhutilICSWriter
())
->
writeICSDocument
(
$root_node
);
}
}
Event Timeline
Log In to Comment