Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110313618
DivinerBookQuery.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
Fri, Apr 25, 17:52
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Apr 27, 17:52 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25805504
Attached To
rPH Phabricator
DivinerBookQuery.php
View Options
<?php
final
class
DivinerBookQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$ids
;
private
$phids
;
private
$names
;
private
$needProjectPHIDs
;
public
function
withIDs
(
array
$ids
)
{
$this
->
ids
=
$ids
;
return
$this
;
}
public
function
withPHIDs
(
array
$phids
)
{
$this
->
phids
=
$phids
;
return
$this
;
}
public
function
withNames
(
array
$names
)
{
$this
->
names
=
$names
;
return
$this
;
}
public
function
needProjectPHIDs
(
$need_phids
)
{
$this
->
needProjectPHIDs
=
$need_phids
;
return
$this
;
}
protected
function
loadPage
()
{
$table
=
new
DivinerLiveBook
();
$conn_r
=
$table
->
establishConnection
(
'r'
);
$data
=
queryfx_all
(
$conn_r
,
'SELECT * FROM %T %Q %Q %Q'
,
$table
->
getTableName
(),
$this
->
buildWhereClause
(
$conn_r
),
$this
->
buildOrderClause
(
$conn_r
),
$this
->
buildLimitClause
(
$conn_r
));
return
$table
->
loadAllFromArray
(
$data
);
}
protected
function
didFilterPage
(
array
$books
)
{
assert_instances_of
(
$books
,
'DivinerLiveBook'
);
if
(
$this
->
needProjectPHIDs
)
{
$edge_query
=
id
(
new
PhabricatorEdgeQuery
())
->
withSourcePHIDs
(
mpull
(
$books
,
'getPHID'
))
->
withEdgeTypes
(
array
(
PhabricatorProjectObjectHasProjectEdgeType
::
EDGECONST
,
));
$edge_query
->
execute
();
foreach
(
$books
as
$book
)
{
$project_phids
=
$edge_query
->
getDestinationPHIDs
(
array
(
$book
->
getPHID
(),
));
$book
->
attachProjectPHIDs
(
$project_phids
);
}
}
return
$books
;
}
protected
function
buildWhereClause
(
AphrontDatabaseConnection
$conn_r
)
{
$where
=
array
();
if
(
$this
->
ids
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'id IN (%Ld)'
,
$this
->
ids
);
}
if
(
$this
->
phids
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'phid IN (%Ls)'
,
$this
->
phids
);
}
if
(
$this
->
names
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'name IN (%Ls)'
,
$this
->
names
);
}
$where
[]
=
$this
->
buildPagingClause
(
$conn_r
);
return
$this
->
formatWhereClause
(
$where
);
}
public
function
getQueryApplicationClass
()
{
return
'PhabricatorDivinerApplication'
;
}
}
Event Timeline
Log In to Comment