2018-09-11 09:04:44 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhrictionDocumentDraftTransaction
|
|
|
|
extends PhrictionDocumentEditTransaction {
|
|
|
|
|
|
|
|
const TRANSACTIONTYPE = 'draft';
|
|
|
|
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
|
|
parent::applyInternalEffects($object, $value);
|
|
|
|
|
|
|
|
$this->getEditor()->setShouldPublishContent($object, false);
|
|
|
|
}
|
|
|
|
|
2018-09-11 13:38:16 -07:00
|
|
|
public function shouldHideForFeed() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-11 10:14:56 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-09-11 09:04:44 -07:00
|
|
|
}
|