Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81379463
PhabricatorDashboardQuery.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
Thu, Sep 5, 16:25
Size
2 KB
Mime Type
text/x-php
Expires
Sat, Sep 7, 16:25 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20557229
Attached To
rPH Phabricator
PhabricatorDashboardQuery.php
View Options
<?php
final
class
PhabricatorDashboardQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$ids
;
private
$phids
;
private
$needPanels
;
public
function
withIDs
(
array
$ids
)
{
$this
->
ids
=
$ids
;
return
$this
;
}
public
function
withPHIDs
(
array
$phids
)
{
$this
->
phids
=
$phids
;
return
$this
;
}
public
function
needPanels
(
$need_panels
)
{
$this
->
needPanels
=
$need_panels
;
return
$this
;
}
protected
function
loadPage
()
{
$table
=
new
PhabricatorDashboard
();
$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
$dashboards
)
{
if
(
$this
->
needPanels
)
{
$edge_query
=
id
(
new
PhabricatorEdgeQuery
())
->
withSourcePHIDs
(
mpull
(
$dashboards
,
'getPHID'
))
->
withEdgeTypes
(
array
(
PhabricatorEdgeConfig
::
TYPE_DASHBOARD_HAS_PANEL
,
));
$edge_query
->
execute
();
$panel_phids
=
$edge_query
->
getDestinationPHIDs
();
if
(
$panel_phids
)
{
$panels
=
id
(
new
PhabricatorDashboardPanelQuery
())
->
setParentQuery
(
$this
)
->
setViewer
(
$this
->
getViewer
())
->
withPHIDs
(
$panel_phids
)
->
execute
();
$panels
=
mpull
(
$panels
,
null
,
'getPHID'
);
}
else
{
$panels
=
array
();
}
foreach
(
$dashboards
as
$dashboard
)
{
$dashboard_phids
=
$edge_query
->
getDestinationPHIDs
(
array
(
$dashboard
->
getPHID
()));
$dashboard_panels
=
array_select_keys
(
$panels
,
$dashboard_phids
);
$dashboard
->
attachPanelPHIDs
(
$dashboard_phids
);
$dashboard
->
attachPanels
(
$dashboard_panels
);
}
}
return
$dashboards
;
}
protected
function
buildWhereClause
(
$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
);
}
$where
[]
=
$this
->
buildPagingClause
(
$conn_r
);
return
$this
->
formatWhereClause
(
$where
);
}
public
function
getQueryApplicationClass
()
{
return
'PhabricatorApplicationDashboard'
;
}
}
Event Timeline
Log In to Comment