@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhrictionDocumentDraftTransaction
4 extends PhrictionDocumentEditTransaction {
5
6 const TRANSACTIONTYPE = 'draft';
7
8 public function applyInternalEffects($object, $value) {
9 parent::applyInternalEffects($object, $value);
10
11 $this->getEditor()->setShouldPublishContent($object, false);
12 }
13
14 public function shouldHideForFeed() {
15 return true;
16 }
17
18 public function validateTransactions($object, array $xactions) {
19 $errors = array();
20
21 // NOTE: We're only validating that you can't edit a document down to
22 // nothing in a draft transaction. Alone, this doesn't prevent you from
23 // creating a document with no content. The content transaction has
24 // validation for that.
25
26 if (!$xactions) {
27 return $errors;
28 }
29
30 $content = $object->getContent()->getContent();
31 if ($this->isEmptyTextTransaction($content, $xactions)) {
32 $errors[] = $this->newRequiredError(
33 pht('Documents must have content.'));
34 }
35
36 return $errors;
37 }
38
39}