1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-09 13:28:29 +01:00
phorge-phorge/src/applications/phriction/xaction/PhrictionDocumentDraftTransaction.php
epriestley 0089ef4b60 Don't show Phriction draft edit events in feed
Summary: Depends on D19663. Ref T13077. When you edit a Phriction draft, don't publish a feed story. (The eventual "Publish" event gets a story.)

Test Plan: Made draft / non-draft / publish edits, only saw feed stories for non-draft and publish edits.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13077

Differential Revision: https://secure.phabricator.com/D19664
2018-09-12 13:56:10 -07:00

39 lines
1,007 B
PHP

<?php
final class PhrictionDocumentDraftTransaction
extends PhrictionDocumentEditTransaction {
const TRANSACTIONTYPE = 'draft';
public function applyInternalEffects($object, $value) {
parent::applyInternalEffects($object, $value);
$this->getEditor()->setShouldPublishContent($object, false);
}
public function shouldHideForFeed() {
return true;
}
public function validateTransactions($object, array $xactions) {
$errors = array();
// NOTE: We're only validating that you can't edit a document down to
// nothing in a draft transaction. Alone, this doesn't prevent you from
// creating a document with no content. The content transaction has
// validation for that.
if (!$xactions) {
return $errors;
}
$content = $object->getContent()->getContent();
if ($this->isEmptyTextTransaction($content, $xactions)) {
$errors[] = $this->newRequiredError(
pht('Documents must have content.'));
}
return $errors;
}
}