Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13980960
D19926.id47551.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D19926.id47551.diff
View Options
diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php
--- a/src/applications/pholio/controller/PholioMockEditController.php
+++ b/src/applications/pholio/controller/PholioMockEditController.php
@@ -162,11 +162,13 @@
->attachFile($file)
->setName(strlen($title) ? $title : $file->getName())
->setDescription($description)
- ->setSequence($sequence);
+ ->setSequence($sequence)
+ ->save();
+
$xactions[] = id(new PholioTransaction())
->setTransactionType(PholioImageFileTransaction::TRANSACTIONTYPE)
->setNewValue(
- array('+' => array($add_image)));
+ array('+' => array($add_image->getPHID())));
$posted_mock_images[] = $add_image;
} else {
$xactions[] = id(new PholioTransaction())
@@ -193,7 +195,7 @@
$xactions[] = id(new PholioTransaction())
->setTransactionType(PholioImageFileTransaction::TRANSACTIONTYPE)
->setNewValue(
- array('-' => array($mock_image)));
+ array('-' => array($mock_image->getPHID())));
}
}
diff --git a/src/applications/pholio/editor/PholioMockEditor.php b/src/applications/pholio/editor/PholioMockEditor.php
--- a/src/applications/pholio/editor/PholioMockEditor.php
+++ b/src/applications/pholio/editor/PholioMockEditor.php
@@ -2,8 +2,6 @@
final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
- private $newImages = array();
-
private $images = array();
public function getEditorApplicationClass() {
@@ -14,16 +12,6 @@
return pht('Pholio Mocks');
}
- private function setNewImages(array $new_images) {
- assert_instances_of($new_images, 'PholioImage');
- $this->newImages = $new_images;
- return $this;
- }
-
- public function getNewImages() {
- return $this->newImages;
- }
-
public function getCreateObjectTitle($author, $object) {
return pht('%s created this mock.', $author);
}
@@ -43,56 +31,6 @@
return $types;
}
- protected function shouldApplyInitialEffects(
- PhabricatorLiskDAO $object,
- array $xactions) {
-
- foreach ($xactions as $xaction) {
- switch ($xaction->getTransactionType()) {
- case PholioImageFileTransaction::TRANSACTIONTYPE:
- return true;
- }
- }
- return false;
- }
-
- protected function applyInitialEffects(
- PhabricatorLiskDAO $object,
- array $xactions) {
-
- $new_images = array();
- foreach ($xactions as $xaction) {
- switch ($xaction->getTransactionType()) {
- case PholioImageFileTransaction::TRANSACTIONTYPE:
- $new_value = $xaction->getNewValue();
- foreach ($new_value as $key => $txn_images) {
- if ($key != '+') {
- continue;
- }
- foreach ($txn_images as $image) {
- $image->save();
- $new_images[] = $image;
- }
- }
- break;
- }
- }
- $this->setNewImages($new_images);
- }
-
- protected function applyFinalEffects(
- PhabricatorLiskDAO $object,
- array $xactions) {
-
- $images = $this->getNewImages();
- foreach ($images as $image) {
- $image->setMockPHID($object->getPHID());
- $image->save();
- }
-
- return $xactions;
- }
-
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
@@ -105,11 +43,11 @@
}
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
- $id = $object->getID();
+ $monogram = $object->getMonogram();
$name = $object->getName();
return id(new PhabricatorMetaMTAMail())
- ->setSubject("M{$id}: {$name}");
+ ->setSubject("{$monogram}: {$name}");
}
protected function getMailTo(PhabricatorLiskDAO $object) {
@@ -150,7 +88,7 @@
$body->addLinkSection(
pht('MOCK DETAIL'),
- PhabricatorEnv::getProductionURI('/M'.$object->getID()));
+ PhabricatorEnv::getProductionURI($object->getURI()));
return $body;
}
diff --git a/src/applications/pholio/xaction/PholioImageFileTransaction.php b/src/applications/pholio/xaction/PholioImageFileTransaction.php
--- a/src/applications/pholio/xaction/PholioImageFileTransaction.php
+++ b/src/applications/pholio/xaction/PholioImageFileTransaction.php
@@ -11,28 +11,34 @@
}
public function generateNewValue($object, $value) {
- $new_value = array();
- foreach ($value as $key => $images) {
- $new_value[$key] = mpull($images, 'getPHID');
- }
- $old = array_fuse($this->getOldValue());
- return $this->getEditor()->getPHIDList($old, $new_value);
+ $editor = $this->getEditor();
+
+ $old_value = $this->getOldValue();
+ $new_value = $value;
+
+ return $editor->getPHIDList($old_value, $new_value);
}
- public function applyInternalEffects($object, $value) {
+ public function applyExternalEffects($object, $value) {
$old_map = array_fuse($this->getOldValue());
$new_map = array_fuse($this->getNewValue());
- $obsolete_map = array_diff_key($old_map, $new_map);
- $images = $object->getActiveImages();
- foreach ($images as $seq => $image) {
- if (isset($obsolete_map[$image->getPHID()])) {
- $image->setIsObsolete(1);
- $image->save();
- unset($images[$seq]);
- }
+ $add_map = array_diff_key($new_map, $old_map);
+ $rem_map = array_diff_key($old_map, $new_map);
+
+ $editor = $this->getEditor();
+
+ foreach ($rem_map as $phid) {
+ $editor->loadPholioImage($object, $phid)
+ ->setIsObsolete(1)
+ ->save();
+ }
+
+ foreach ($add_map as $phid) {
+ $editor->loadPholioImage($object, $phid)
+ ->setMockPHID($object->getPHID())
+ ->save();
}
- $object->attachImages($images);
}
public function getTitle() {
@@ -95,18 +101,20 @@
}
public function extractFilePHIDs($object, $value) {
- $images = $this->getEditor()->getNewImages();
- $images = mpull($images, null, 'getPHID');
+ $editor = $this->getEditor();
+ // NOTE: This method is a little weird (and includes ALL the file PHIDs,
+ // including old file PHIDs) because we currently don't have a storage
+ // object when called. This might change at some point.
+
+ $new_phids = $value;
$file_phids = array();
- foreach ($value as $image_phid) {
- $image = idx($images, $image_phid);
- if (!$image) {
- continue;
- }
- $file_phids[] = $image->getFilePHID();
+ foreach ($new_phids as $phid) {
+ $file_phids[] = $editor->loadPholioImage($object, $phid)
+ ->getFilePHID();
}
+
return $file_phids;
}
@@ -114,7 +122,7 @@
$object,
PhabricatorApplicationTransaction $u,
PhabricatorApplicationTransaction $v) {
- return $this->getEditor()->mergePHIDOrEdgeTransactions($u, $v);
+ return $this->getEditor()->mergePHIDOrEdgeTransactions($u, $v);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 1:34 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6727189
Default Alt Text
D19926.id47551.diff (6 KB)
Attached To
Mode
D19926: Implement Pholio file add/remove transactions without "applyInitialEffects"
Attached
Detach File
Event Timeline
Log In to Comment