1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Implement PhabricatorDestructibleInterface in Phame

Summary: Allows Blogs and Posts to be destroyed. Fixes T9756

Test Plan: Test `bin/remove destroy POST` and `bin/remove destroy BLOG` to great success.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9756

Differential Revision: https://secure.phabricator.com/D14586
This commit is contained in:
Chad Little 2015-11-28 13:01:11 -08:00
parent a6e24cb2be
commit e8a39ca3e5
3 changed files with 33 additions and 0 deletions

View file

@ -7581,6 +7581,7 @@ phutil_register_library_map(array(
'PhabricatorSubscribableInterface',
'PhabricatorFlaggableInterface',
'PhabricatorProjectInterface',
'PhabricatorDestructibleInterface',
'PhabricatorApplicationTransactionInterface',
),
'PhameBlogArchiveController' => 'PhameBlogController',
@ -7613,6 +7614,7 @@ phutil_register_library_map(array(
'PhabricatorProjectInterface',
'PhabricatorApplicationTransactionInterface',
'PhabricatorSubscribableInterface',
'PhabricatorDestructibleInterface',
'PhabricatorTokenReceiverInterface',
),
'PhamePostCommentController' => 'PhamePostController',

View file

@ -7,6 +7,7 @@ final class PhameBlog extends PhameDAO
PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface,
PhabricatorProjectInterface,
PhabricatorDestructibleInterface,
PhabricatorApplicationTransactionInterface {
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
@ -320,6 +321,23 @@ final class PhameBlog extends PhameDAO
return (bool)$this->getPHID();
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$posts = id(new PhamePost())
->loadAllWhere('blogPHID = %s', $this->getPHID());
foreach ($posts as $post) {
$post->delete();
}
$this->delete();
$this->saveTransaction();
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -8,6 +8,7 @@ final class PhamePost extends PhameDAO
PhabricatorProjectInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorSubscribableInterface,
PhabricatorDestructibleInterface,
PhabricatorTokenReceiverInterface {
const MARKUP_FIELD_BODY = 'markup:body';
@ -252,6 +253,18 @@ final class PhamePost extends PhameDAO
return $timeline;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */