Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F116798728
FundBackerQuery.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
Mon, Jun 9, 08:12
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Jun 11, 08:12 (2 d)
Engine
blob
Format
Raw Data
Handle
26651689
Attached To
rPH Phabricator
FundBackerQuery.php
View Options
<?php
final
class
FundBackerQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$ids
;
private
$phids
;
private
$initiativePHIDs
;
private
$backerPHIDs
;
public
function
withIDs
(
array
$ids
)
{
$this
->
ids
=
$ids
;
return
$this
;
}
public
function
withPHIDs
(
array
$phids
)
{
$this
->
phids
=
$phids
;
return
$this
;
}
public
function
withInitiativePHIDs
(
array
$phids
)
{
$this
->
initiativePHIDs
=
$phids
;
return
$this
;
}
public
function
withBackerPHIDs
(
array
$phids
)
{
$this
->
backerPHIDs
=
$phids
;
return
$this
;
}
protected
function
loadPage
()
{
$table
=
new
FundBacker
();
$conn_r
=
$table
->
establishConnection
(
'r'
);
$rows
=
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
(
$rows
);
}
protected
function
willFilterPage
(
array
$backers
)
{
$initiative_phids
=
mpull
(
$backers
,
'getInitiativePHID'
);
$initiatives
=
id
(
new
PhabricatorObjectQuery
())
->
setParentQuery
(
$this
)
->
setViewer
(
$this
->
getViewer
())
->
withPHIDs
(
$initiative_phids
)
->
execute
();
$initiatives
=
mpull
(
$initiatives
,
null
,
'getPHID'
);
foreach
(
$backers
as
$backer
)
{
$initiative_phid
=
$backer
->
getInitiativePHID
();
$initiative
=
idx
(
$initiatives
,
$initiative_phid
);
$backer
->
attachInitiative
(
$initiative
);
}
return
$backers
;
}
private
function
buildWhereClause
(
AphrontDatabaseConnection
$conn_r
)
{
$where
=
array
();
$where
[]
=
$this
->
buildPagingClause
(
$conn_r
);
if
(
$this
->
ids
!==
null
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'id IN (%Ld)'
,
$this
->
ids
);
}
if
(
$this
->
phids
!==
null
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'phid IN (%Ls)'
,
$this
->
phids
);
}
if
(
$this
->
initiativePHIDs
!==
null
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'initiativePHID IN (%Ls)'
,
$this
->
initiativePHIDs
);
}
if
(
$this
->
backerPHIDs
!==
null
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'backerPHID IN (%Ls)'
,
$this
->
backerPHIDs
);
}
return
$this
->
formatWhereClause
(
$where
);
}
public
function
getQueryApplicationClass
()
{
return
'PhabricatorFundApplication'
;
}
}
Event Timeline
Log In to Comment