3 final class ManiphestTaskCoverImageTransaction
4 extends ManiphestTaskTransactionType
{
6 const TRANSACTIONTYPE
= 'cover-image';
8 public function generateOldValue($object) {
9 return $object->getCoverImageFilePHID();
12 public function applyInternalEffects($object, $value) {
16 $file = id(new PhabricatorFileQuery())
17 ->setViewer($this->getActor())
18 ->withPHIDs(array($file_phid))
24 if (!$file ||
!$file->isTransformableImage()) {
25 $object->setProperty('cover.filePHID', null);
26 $object->setProperty('cover.thumbnailPHID', null);
30 $xform_key = PhabricatorFileThumbnailTransform
::TRANSFORM_WORKCARD
;
31 $xform = PhabricatorFileTransform
::getTransformByKey($xform_key)
32 ->executeTransform($file);
34 $object->setProperty('cover.filePHID', $file->getPHID());
35 $object->setProperty('cover.thumbnailPHID', $xform->getPHID());
38 public function getTitle() {
39 $old = $this->getOldValue();
40 $new = $this->getNewValue();
44 '%s set the cover image to %s.',
45 $this->renderAuthor(),
46 $this->renderHandle($new));
50 '%s updated the cover image to %s.',
51 $this->renderAuthor(),
52 $this->renderHandle($new));
56 public function getTitleForFeed() {
57 $old = $this->getOldValue();
60 '%s added a cover image to %s.',
61 $this->renderAuthor(),
62 $this->renderObject());
66 '%s updated the cover image for %s.',
67 $this->renderAuthor(),
68 $this->renderObject());
71 public function validateTransactions($object, array $xactions) {
73 $viewer = $this->getActor();
75 foreach ($xactions as $xaction) {
76 $file_phid = $xaction->getNewValue();
78 $file = id(new PhabricatorFileQuery())
80 ->withPHIDs(array($file_phid))
84 $errors[] = $this->newInvalidError(
86 'File PHID ("%s") is invalid, or you do not have permission '.
93 if (!$file->isViewableImage()) {
94 $errors[] = $this->newInvalidError(
96 'File ("%s", with MIME type "%s") is not a viewable image file.',
98 $file->getMimeType()),
103 if (!$file->isTransformableImage()) {
104 $errors[] = $this->newInvalidError(
106 'File ("%s", with MIME type "%s") can not be transformed into '.
107 'a thumbnail. You may be missing support for this file type in '.
108 'the "GD" extension.',
110 $file->getMimeType()),
119 public function getIcon() {