1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-11 03:44:48 +01:00

Implement DestructibleInterface for dashboards and panels

Summary: Fixes T5471.

Test Plan: Used `bin/remove destroy` to destroy a dashboard and a panel.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5471

Differential Revision: https://secure.phabricator.com/D10283
This commit is contained in:
epriestley 2014-08-18 13:15:13 -07:00
parent cd82b90c15
commit 211a93529b
3 changed files with 39 additions and 2 deletions

View file

@ -4231,6 +4231,7 @@ phutil_register_library_map(array(
'PhabricatorDashboard' => array(
'PhabricatorDashboardDAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
),
'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController',
'PhabricatorDashboardApplication' => 'PhabricatorApplication',
@ -4249,6 +4250,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardDAO',
'PhabricatorPolicyInterface',
'PhabricatorCustomFieldInterface',
'PhabricatorDestructibleInterface',
),
'PhabricatorDashboardPanelArchiveController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelCoreCustomField' => array(

View file

@ -4,7 +4,9 @@
* A collection of dashboard panels with a specific layout.
*/
final class PhabricatorDashboard extends PhabricatorDashboardDAO
implements PhabricatorPolicyInterface {
implements
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
protected $name;
protected $viewPolicy;
@ -104,4 +106,24 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$installs = id(new PhabricatorDashboardInstall())->loadAllWhere(
'dashboardPHID = %s',
$this->getPHID());
foreach ($installs as $install) {
$install->delete();
}
$this->delete();
$this->saveTransaction();
}
}

View file

@ -7,7 +7,8 @@ final class PhabricatorDashboardPanel
extends PhabricatorDashboardDAO
implements
PhabricatorPolicyInterface,
PhabricatorCustomFieldInterface {
PhabricatorCustomFieldInterface,
PhabricatorDestructibleInterface {
protected $name;
protected $panelType;
@ -131,4 +132,16 @@ final class PhabricatorDashboardPanel
return $this;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
}