Page MenuHomePhabricator

D19911.diff
No OneTemporary

D19911.diff

diff --git a/src/applications/pholio/controller/PholioImageUploadController.php b/src/applications/pholio/controller/PholioImageUploadController.php
--- a/src/applications/pholio/controller/PholioImageUploadController.php
+++ b/src/applications/pholio/controller/PholioImageUploadController.php
@@ -22,7 +22,7 @@
$title = $file->getName();
}
- $image = id(new PholioImage())
+ $image = PholioImage::initializeNewImage()
->attachFile($file)
->setName($title)
->setDescription($description)
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
@@ -140,7 +140,7 @@
$sequence = $sequence_map[$file_phid];
if ($replaces_image_phid) {
- $replace_image = id(new PholioImage())
+ $replace_image = PholioImage::initializeNewImage()
->setReplacesImagePHID($replaces_image_phid)
->setFilePhid($file_phid)
->attachFile($file)
@@ -153,7 +153,7 @@
->setNewValue($replace_image);
$posted_mock_images[] = $replace_image;
} else if (!$existing_image) { // this is an add
- $add_image = id(new PholioImage())
+ $add_image = PholioImage::initializeNewImage()
->setFilePhid($file_phid)
->attachFile($file)
->setName(strlen($title) ? $title : $file->getName())
diff --git a/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php b/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php
--- a/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php
+++ b/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php
@@ -41,10 +41,11 @@
$sequence = 0;
$images = array();
foreach ($files as $file) {
- $image = new PholioImage();
- $image->setFilePHID($file->getPHID());
- $image->setSequence($sequence++);
- $image->attachMock($mock);
+ $image = PholioImage::initializeNewImage()
+ ->setFilePHID($file->getPHID())
+ ->setSequence($sequence++)
+ ->attachMock($mock);
+
$images[] = $image;
}
diff --git a/src/applications/pholio/storage/PholioImage.php b/src/applications/pholio/storage/PholioImage.php
--- a/src/applications/pholio/storage/PholioImage.php
+++ b/src/applications/pholio/storage/PholioImage.php
@@ -9,16 +9,23 @@
protected $mockID;
protected $filePHID;
- protected $name = '';
- protected $description = '';
+ protected $name;
+ protected $description;
protected $sequence;
- protected $isObsolete = 0;
+ protected $isObsolete;
protected $replacesImagePHID = null;
private $inlineComments = self::ATTACHABLE;
private $file = self::ATTACHABLE;
private $mock = self::ATTACHABLE;
+ public static function initializeNewImage() {
+ return id(new self())
+ ->setName('')
+ ->setDescription('')
+ ->setIsObsolete(0);
+ }
+
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
@@ -43,8 +50,8 @@
) + parent::getConfiguration();
}
- public function generatePHID() {
- return PhabricatorPHID::generateNewPHID(PholioImagePHIDType::TYPECONST);
+ public function getPHIDType() {
+ return PholioImagePHIDType::TYPECONST;
}
public function attachFile(PhabricatorFile $file) {
@@ -67,7 +74,6 @@
return $this->mock;
}
-
public function attachInlineComments(array $inline_comments) {
assert_instances_of($inline_comments, 'PholioTransactionComment');
$this->inlineComments = $inline_comments;
diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php
--- a/src/applications/pholio/storage/PholioMock.php
+++ b/src/applications/pholio/storage/PholioMock.php
@@ -295,9 +295,10 @@
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
- $images = id(new PholioImage())->loadAllWhere(
- 'mockID = %d',
- $this->getID());
+ $images = id(new PholioImageQuery())
+ ->setViewer($engine->getViewer())
+ ->withMockIDs(array($this->getID()))
+ ->execute();
foreach ($images as $image) {
$image->delete();
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 6:25 PM (41 m, 33 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6911556
Default Alt Text
D19911.diff (4 KB)

Event Timeline