diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 7e3ab8e8f6..3fd46e6365 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3611,6 +3611,7 @@ phutil_register_library_map(array( 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorSubscribableInterface', 3 => 'PhabricatorApplicationTransactionInterface', + 4 => 'PhabricatorDestructableInterface', ), 'LegalpadDocumentBody' => array( diff --git a/src/applications/legalpad/storage/LegalpadDocument.php b/src/applications/legalpad/storage/LegalpadDocument.php index 4f8378f0a1..a29047c4e8 100644 --- a/src/applications/legalpad/storage/LegalpadDocument.php +++ b/src/applications/legalpad/storage/LegalpadDocument.php @@ -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(); + } + }