Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121995338
ReleephRequestQuery.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
Tue, Jul 15, 06:04
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Jul 17, 06:04 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27422212
Attached To
rPH Phabricator
ReleephRequestQuery.php
View Options
<?php
final
class
ReleephRequestQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$requestedCommitPHIDs
;
private
$commitToRevMap
;
private
$ids
;
private
$phids
;
public
function
withIDs
(
array
$ids
)
{
$this
->
ids
=
$ids
;
return
$this
;
}
public
function
withPHIDs
(
array
$phids
)
{
$this
->
phids
=
$phids
;
return
$this
;
}
public
function
getRevisionPHID
(
$commit_phid
)
{
if
(
$this
->
commitToRevMap
)
{
return
idx
(
$this
->
commitToRevMap
,
$commit_phid
,
null
);
}
return
null
;
}
public
function
withRequestedCommitPHIDs
(
array
$requested_commit_phids
)
{
$this
->
requestedCommitPHIDs
=
$requested_commit_phids
;
return
$this
;
}
public
function
withRevisionPHIDs
(
array
$revision_phids
)
{
$type
=
PhabricatorEdgeConfig
::
TYPE_DREV_HAS_COMMIT
;
$edges
=
id
(
new
PhabricatorEdgeQuery
())
->
withSourcePHIDs
(
$revision_phids
)
->
withEdgeTypes
(
array
(
$type
))
->
execute
();
$this
->
commitToRevMap
=
array
();
foreach
(
$edges
as
$revision_phid
=>
$edge
)
{
foreach
(
$edge
[
$type
]
as
$commitPHID
=>
$item
)
{
$this
->
commitToRevMap
[
$commitPHID
]
=
$revision_phid
;
}
}
$this
->
requestedCommitPHIDs
=
array_keys
(
$this
->
commitToRevMap
);
}
public
function
loadPage
()
{
$table
=
new
ReleephRequest
();
$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
);
}
private
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
->
requestedCommitPHIDs
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'requestCommitPHID IN (%Ls)'
,
$this
->
requestedCommitPHIDs
);
}
$where
[]
=
$this
->
buildPagingClause
(
$conn_r
);
return
$this
->
formatWhereClause
(
$where
);
}
}
Event Timeline
Log In to Comment