Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F804788
PhabricatorDashboardCopyController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorDashboardCopyController.php
View Options
<?php
final
class
PhabricatorDashboardCopyController
extends
PhabricatorDashboardController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$dashboard
=
id
(
new
PhabricatorDashboardQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
needPanels
(
true
)
->
executeOne
();
if
(!
$dashboard
)
{
return
new
Aphront404Response
();
}
$manage_uri
=
$this
->
getApplicationURI
(
'manage/'
.
$dashboard
->
getID
().
'/'
);
if
(
$request
->
isFormPost
())
{
$copy
=
PhabricatorDashboard
::
initializeNewDashboard
(
$viewer
);
$copy
=
PhabricatorDashboard
::
copyDashboard
(
$copy
,
$dashboard
);
$copy
->
setName
(
pht
(
'Copy of %s'
,
$copy
->
getName
()));
// Set up all the edges for the new dashboard.
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhabricatorDashboardTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_EDGE
)
->
setMetadataValue
(
'edge:type'
,
PhabricatorDashboardDashboardHasPanelEdgeType
::
EDGECONST
)
->
setNewValue
(
array
(
'='
=>
array_fuse
(
$dashboard
->
getPanelPHIDs
()),
));
$editor
=
id
(
new
PhabricatorDashboardTransactionEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnMissingFields
(
true
)
->
setContinueOnNoEffect
(
true
)
->
applyTransactions
(
$copy
,
$xactions
);
$manage_uri
=
$this
->
getApplicationURI
(
'edit/'
.
$copy
->
getID
().
'/'
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$manage_uri
);
}
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Copy Dashboard'
))
->
appendParagraph
(
pht
(
'Create a copy of the dashboard "%s"?'
,
phutil_tag
(
'strong'
,
array
(),
$dashboard
->
getName
())))
->
addCancelButton
(
$manage_uri
)
->
addSubmitButton
(
pht
(
'Create Copy'
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, May 29, 12:50 PM (21 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
182903
Default Alt Text
PhabricatorDashboardCopyController.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment