1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Allow projects to be deleted with ./bin/remove destroy.

Summary: Fixes T5235. Implement `PhabricatorDestructableInterface` on `PhabricatorProject` so that projects can be deleted with `./bin/remove destroy`.

Test Plan: Created (and then destroyed) a test project. Verified that the corresponding objects (project, slugs and workboard columns) were removed from the database.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T5235

Differential Revision: https://secure.phabricator.com/D9352
This commit is contained in:
Joshua Spence 2014-06-02 17:10:29 -07:00 committed by epriestley
parent 1e2a592ceb
commit c2eff7c216
2 changed files with 38 additions and 2 deletions

View file

@ -5,7 +5,8 @@ final class PhabricatorProject extends PhabricatorProjectDAO
PhabricatorFlaggableInterface,
PhabricatorPolicyInterface,
PhabricatorSubscribableInterface,
PhabricatorCustomFieldInterface {
PhabricatorCustomFieldInterface,
PhabricatorDestructableInterface {
protected $name;
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
@ -247,4 +248,27 @@ final class PhabricatorProject extends PhabricatorProjectDAO
}
/* -( PhabricatorDestructableInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$columns = id(new PhabricatorProjectColumn())
->loadAllWhere('projectPHID = %s', $this->getPHID());
foreach ($columns as $column) {
$engine->destroyObject($column);
}
$slugs = id(new PhabricatorProjectSlug())
->loadAllWhere('projectPHID = %s', $this->getPHID());
foreach ($slugs as $slug) {
$slug->delete();
}
$this->saveTransaction();
}
}

View file

@ -2,7 +2,8 @@
final class PhabricatorProjectColumn
extends PhabricatorProjectDAO
implements PhabricatorPolicyInterface {
implements PhabricatorPolicyInterface,
PhabricatorDestructableInterface {
const STATUS_ACTIVE = 0;
const STATUS_DELETED = 1;
@ -87,4 +88,15 @@ final class PhabricatorProjectColumn
return pht('Users must be able to see a project to see its board.');
}
/* -( PhabricatorDestructableInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
}