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

Allow pastes to be destroyed

Summary: Fixes T6186.

Test Plan:
  - Used `bin/remove destroy Pxxx` to destroy a paste.
  - Verified file, transactions, etc., were destroyed.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6186

Differential Revision: https://secure.phabricator.com/D10563
This commit is contained in:
epriestley 2014-09-25 13:42:38 -07:00
parent 3c527cc472
commit 9dee67618d
2 changed files with 41 additions and 1 deletions

View file

@ -4855,6 +4855,8 @@ phutil_register_library_map(array(
'PhabricatorMentionableInterface', 'PhabricatorMentionableInterface',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorProjectInterface', 'PhabricatorProjectInterface',
'PhabricatorDestructibleInterface',
'PhabricatorApplicationTransactionInterface',
), ),
'PhabricatorPasteApplication' => 'PhabricatorApplication', 'PhabricatorPasteApplication' => 'PhabricatorApplication',
'PhabricatorPasteCommentController' => 'PhabricatorPasteController', 'PhabricatorPasteCommentController' => 'PhabricatorPasteController',

View file

@ -7,7 +7,9 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
PhabricatorFlaggableInterface, PhabricatorFlaggableInterface,
PhabricatorMentionableInterface, PhabricatorMentionableInterface,
PhabricatorPolicyInterface, PhabricatorPolicyInterface,
PhabricatorProjectInterface { PhabricatorProjectInterface,
PhabricatorDestructibleInterface,
PhabricatorApplicationTransactionInterface {
protected $title; protected $title;
protected $authorPHID; protected $authorPHID;
@ -152,4 +154,40 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
return pht('The author of a paste can always view and edit it.'); return pht('The author of a paste can always view and edit it.');
} }
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
if ($this->filePHID) {
$file = id(new PhabricatorFileQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs(array($this->filePHID))
->executeOne();
if ($file) {
$engine->destroyObject($file);
}
}
$this->delete();
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new PhabricatorPasteEditor();
}
public function getApplicationTransactionObject() {
return $this;
}
public function getApplicationTransactionTemplate() {
return new PhabricatorPasteTransaction();
}
} }