Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101355097
PhameQueryPostsConduitAPIMethod.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, Feb 8, 14:46
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Feb 10, 14:46 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
24142579
Attached To
rPH Phabricator
PhameQueryPostsConduitAPIMethod.php
View Options
<?php
final
class
PhameQueryPostsConduitAPIMethod
extends
PhameConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'phame.queryposts'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Query phame posts.'
);
}
public
function
getMethodStatus
()
{
return
self
::
METHOD_STATUS_UNSTABLE
;
}
protected
function
defineParamTypes
()
{
return
array
(
'ids'
=>
'optional list<int>'
,
'phids'
=>
'optional list<phid>'
,
'blogPHIDs'
=>
'optional list<phid>'
,
'bloggerPHIDs'
=>
'optional list<phid>'
,
'published'
=>
'optional bool'
,
'publishedAfter'
=>
'optional date'
,
'before'
=>
'optional int'
,
'after'
=>
'optional int'
,
'limit'
=>
'optional int'
,
);
}
protected
function
defineReturnType
()
{
return
'list<dict>'
;
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$query
=
new
PhamePostQuery
();
$query
->
setViewer
(
$request
->
getUser
());
$ids
=
$request
->
getValue
(
'ids'
,
array
());
if
(
$ids
)
{
$query
->
withIDs
(
$ids
);
}
$phids
=
$request
->
getValue
(
'phids'
,
array
());
if
(
$phids
)
{
$query
->
withPHIDs
(
$phids
);
}
$blog_phids
=
$request
->
getValue
(
'blogPHIDs'
,
array
());
if
(
$blog_phids
)
{
$query
->
withBlogPHIDs
(
$blog_phids
);
}
$blogger_phids
=
$request
->
getValue
(
'bloggerPHIDs'
,
array
());
if
(
$blogger_phids
)
{
$query
->
withBloggerPHIDs
(
$blogger_phids
);
}
$published
=
$request
->
getValue
(
'published'
,
null
);
if
(
$published
===
true
)
{
$query
->
withVisibility
(
PhameConstants
::
VISIBILITY_PUBLISHED
);
}
else
if
(
$published
===
false
)
{
$query
->
withVisibility
(
PhameConstants
::
VISIBILITY_DRAFT
);
}
$published_after
=
$request
->
getValue
(
'publishedAfter'
,
null
);
if
(
$published_after
!==
null
)
{
$query
->
withPublishedAfter
(
$published_after
);
}
$after
=
$request
->
getValue
(
'after'
,
null
);
if
(
$after
!==
null
)
{
$query
->
setAfterID
(
$after
);
}
$before
=
$request
->
getValue
(
'before'
,
null
);
if
(
$before
!==
null
)
{
$query
->
setBeforeID
(
$before
);
}
$limit
=
$request
->
getValue
(
'limit'
,
null
);
if
(
$limit
!==
null
)
{
$query
->
setLimit
(
$limit
);
}
$posts
=
$query
->
execute
();
$results
=
array
();
foreach
(
$posts
as
$post
)
{
$results
[]
=
$post
->
toDictionary
();
}
return
$results
;
}
}
Event Timeline
Log In to Comment