@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
at upstream/main 32 lines 894 B view raw
1<?php 2 3final class PhrictionDocumentContentTransaction 4 extends PhrictionDocumentEditTransaction { 5 6 const TRANSACTIONTYPE = 'content'; 7 8 public function applyInternalEffects($object, $value) { 9 parent::applyInternalEffects($object, $value); 10 11 $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); 12 13 $this->getEditor()->setShouldPublishContent($object, true); 14 } 15 16 public function validateTransactions($object, array $xactions) { 17 $errors = array(); 18 19 // NOTE: This is slightly different from the draft validation. Here, 20 // we're validating that: you can't edit away a document; and you can't 21 // create an empty document. 22 23 $content = $object->getContent()->getContent(); 24 if ($this->isEmptyTextTransaction($content, $xactions)) { 25 $errors[] = $this->newRequiredError( 26 pht('Documents must have content.')); 27 } 28 29 return $errors; 30 } 31 32}