1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Allow Legalpad documents to be destroyed with bin/remove destroy

Summary: Ref T3116. Support permanent destruction of legal document objects.

Test Plan: Ran `bin/remove destroy L1`, saw it clean up the document body, signatures, transactions and edges.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T3116

Differential Revision: https://secure.phabricator.com/D9775
This commit is contained in:
epriestley 2014-06-29 07:50:53 -07:00
parent c9184db94a
commit 94926698e0
2 changed files with 30 additions and 1 deletions

View file

@ -3611,6 +3611,7 @@ phutil_register_library_map(array(
1 => 'PhabricatorPolicyInterface',
2 => 'PhabricatorSubscribableInterface',
3 => 'PhabricatorApplicationTransactionInterface',
4 => 'PhabricatorDestructableInterface',
),
'LegalpadDocumentBody' =>
array(

View file

@ -4,7 +4,8 @@ final class LegalpadDocument extends LegalpadDAO
implements
PhabricatorPolicyInterface,
PhabricatorSubscribableInterface,
PhabricatorApplicationTransactionInterface {
PhabricatorApplicationTransactionInterface,
PhabricatorDestructableInterface {
protected $title;
protected $contributorCount;
@ -170,4 +171,31 @@ final class LegalpadDocument extends LegalpadDAO
return new LegalpadTransaction();
}
/* -( PhabricatorDestructableInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$bodies = id(new LegalpadDocumentBody())->loadAllWhere(
'documentPHID = %s',
$this->getPHID());
foreach ($bodies as $body) {
$body->delete();
}
$signatures = id(new LegalpadDocumentSignature())->loadAllWhere(
'documentPHID = %s',
$this->getPHID());
foreach ($signatures as $signature) {
$signature->delete();
}
$this->saveTransaction();
}
}