Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F111895306
PhabricatorDashboardPanelRenderingEngine.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, May 5, 20:56
Size
2 KB
Mime Type
text/x-php
Expires
Wed, May 7, 20:56 (2 d)
Engine
blob
Format
Raw Data
Handle
25990298
Attached To
rPH Phabricator
PhabricatorDashboardPanelRenderingEngine.php
View Options
<?php
final
class
PhabricatorDashboardPanelRenderingEngine
extends
Phobject
{
private
$panel
;
private
$viewer
;
private
$enableAsyncRendering
;
/**
* Allow the engine to render the panel via Ajax.
*/
public
function
setEnableAsyncRendering
(
$enable
)
{
$this
->
enableAsyncRendering
=
$enable
;
return
$this
;
}
public
function
setViewer
(
PhabricatorUser
$viewer
)
{
$this
->
viewer
=
$viewer
;
return
$this
;
}
public
function
setPanel
(
PhabricatorDashboardPanel
$panel
)
{
$this
->
panel
=
$panel
;
return
$this
;
}
public
function
renderPanel
()
{
$panel
=
$this
->
panel
;
$viewer
=
$this
->
viewer
;
if
(!
$panel
)
{
return
$this
->
renderErrorPanel
(
pht
(
'Missing Panel'
),
pht
(
'This panel does not exist.'
));
}
$panel_type
=
$panel
->
getImplementation
();
if
(!
$panel_type
)
{
return
$this
->
renderErrorPanel
(
$panel
->
getName
(),
pht
(
'This panel has type "%s", but that panel type is not known to '
.
'Phabricator.'
,
$panel
->
getPanelType
()));
}
if
(
$this
->
enableAsyncRendering
)
{
if
(
$panel_type
->
shouldRenderAsync
())
{
return
$this
->
renderAsyncPanel
(
$panel
);
}
}
try
{
return
$panel_type
->
renderPanel
(
$viewer
,
$panel
);
}
catch
(
Exception
$ex
)
{
return
$this
->
renderErrorPanel
(
$panel
->
getName
(),
pht
(
'%s: %s'
,
phutil_tag
(
'strong'
,
array
(),
get_class
(
$ex
)),
$ex
->
getMessage
()));
}
}
private
function
renderErrorPanel
(
$title
,
$body
)
{
return
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
$title
)
->
setFormErrors
(
array
(
$body
));
}
private
function
renderAsyncPanel
(
PhabricatorDashboardPanel
$panel
)
{
$panel_id
=
celerity_generate_unique_node_id
();
Javelin
::
initBehavior
(
'dashboard-async-panel'
,
array
(
'panelID'
=>
$panel_id
,
'uri'
=>
'/dashboard/panel/render/'
.
$panel
->
getID
().
'/'
,
));
return
id
(
new
PHUIObjectBoxView
())
->
addSigil
(
'dashboard-panel'
)
->
setMetadata
(
array
(
'objectPHID'
=>
$panel
->
getPHID
()))
->
setHeaderText
(
$panel
->
getName
())
->
setID
(
$panel_id
)
->
appendChild
(
pht
(
'Loading...'
));
}
}
Event Timeline
Log In to Comment