Differential D25475 Diff 1815 src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
Show All 21 Lines | public function applyInternalEffects($object, $value) { | ||||
} | } | ||||
if (!$file || !$file->isTransformableImage()) { | if (!$file || !$file->isTransformableImage()) { | ||||
$object->setProperty('cover.filePHID', null); | $object->setProperty('cover.filePHID', null); | ||||
$object->setProperty('cover.thumbnailPHID', null); | $object->setProperty('cover.thumbnailPHID', null); | ||||
return; | return; | ||||
} | } | ||||
// Generate an image transformation, usually smaller (orphan now). | |||||
$xform_key = PhabricatorFileThumbnailTransform::TRANSFORM_WORKCARD; | $xform_key = PhabricatorFileThumbnailTransform::TRANSFORM_WORKCARD; | ||||
$xform = PhabricatorFileTransform::getTransformByKey($xform_key) | $xform = PhabricatorFileTransform::getTransformByKey($xform_key) | ||||
->executeTransform($file); | ->executeTransform($file); | ||||
// Make that image transformation non-orphan. | |||||
id(new PhabricatorTransformedFile()) | |||||
->setOriginalPHID($file_phid) | |||||
->setTransformedPHID($xform->getPHID()) | |||||
->setTransform($xform_key) | |||||
->save(); | |||||
$object->setProperty('cover.filePHID', $file->getPHID()); | $object->setProperty('cover.filePHID', $file->getPHID()); | ||||
$object->setProperty('cover.thumbnailPHID', $xform->getPHID()); | $object->setProperty('cover.thumbnailPHID', $xform->getPHID()); | ||||
} | } | ||||
public function applyExternalEffects($object, $value) { | |||||
// If the File has a Cover Image, attach that as side-effect. | |||||
// Otherwise, the Cover Image may be invisible to participants. | |||||
$file_phid = $object->getProperty('cover.filePHID'); | |||||
if ($file_phid) { | |||||
PhabricatorFile::attachFileToObject($file_phid, $object->getPHID()); | |||||
} | |||||
valerio.bozzolan: 🔶 I think that this connection should be executed as default by `PhabricatorTransformedFile`… | |||||
Done Inline ActionsLooking at PhabricatorFileTestCase it seems normal to do this kind of things manually. valerio.bozzolan: Looking at `PhabricatorFileTestCase` it seems normal to do this kind of things manually. | |||||
} | |||||
public function getTitle() { | public function getTitle() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
if ($old === null) { | if ($old === null) { | ||||
return pht( | return pht( | ||||
'%s set the cover image to %s.', | '%s set the cover image to %s.', | ||||
$this->renderAuthor(), | $this->renderAuthor(), | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
🔶 I think that this connection should be executed as default by PhabricatorTransformedFile executeTransform() as default. But I'm not sure, and I also don't know how to do that in that way. Thanks for any counter-idea.