Changeset View
Changeset View
Standalone View
Standalone View
src/applications/pholio/controller/PholioMockEditController.php
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
$posted_mock_images[] = $replace_image; | $posted_mock_images[] = $replace_image; | ||||
} else if (!$existing_image) { // this is an add | } else if (!$existing_image) { // this is an add | ||||
$add_image = PholioImage::initializeNewImage() | $add_image = PholioImage::initializeNewImage() | ||||
->setAuthorPHID($viewer->getPHID()) | ->setAuthorPHID($viewer->getPHID()) | ||||
->setFilePHID($file_phid) | ->setFilePHID($file_phid) | ||||
->attachFile($file) | ->attachFile($file) | ||||
->setName(strlen($title) ? $title : $file->getName()) | ->setName(strlen($title) ? $title : $file->getName()) | ||||
->setDescription($description) | ->setDescription($description) | ||||
->setSequence($sequence); | ->setSequence($sequence) | ||||
->save(); | |||||
$xactions[] = id(new PholioTransaction()) | $xactions[] = id(new PholioTransaction()) | ||||
->setTransactionType(PholioImageFileTransaction::TRANSACTIONTYPE) | ->setTransactionType(PholioImageFileTransaction::TRANSACTIONTYPE) | ||||
->setNewValue( | ->setNewValue( | ||||
array('+' => array($add_image))); | array('+' => array($add_image->getPHID()))); | ||||
$posted_mock_images[] = $add_image; | $posted_mock_images[] = $add_image; | ||||
} else { | } else { | ||||
$xactions[] = id(new PholioTransaction()) | $xactions[] = id(new PholioTransaction()) | ||||
->setTransactionType(PholioImageNameTransaction::TRANSACTIONTYPE) | ->setTransactionType(PholioImageNameTransaction::TRANSACTIONTYPE) | ||||
->setNewValue( | ->setNewValue( | ||||
array($existing_image->getPHID() => $title)); | array($existing_image->getPHID() => $title)); | ||||
$xactions[] = id(new PholioTransaction()) | $xactions[] = id(new PholioTransaction()) | ||||
->setTransactionType( | ->setTransactionType( | ||||
Show All 10 Lines | if ($request->isFormPost()) { | ||||
} | } | ||||
} | } | ||||
foreach ($mock_images as $file_phid => $mock_image) { | foreach ($mock_images as $file_phid => $mock_image) { | ||||
if (!isset($files[$file_phid]) && !isset($replaces[$file_phid])) { | if (!isset($files[$file_phid]) && !isset($replaces[$file_phid])) { | ||||
// this is an outright delete | // this is an outright delete | ||||
$xactions[] = id(new PholioTransaction()) | $xactions[] = id(new PholioTransaction()) | ||||
->setTransactionType(PholioImageFileTransaction::TRANSACTIONTYPE) | ->setTransactionType(PholioImageFileTransaction::TRANSACTIONTYPE) | ||||
->setNewValue( | ->setNewValue( | ||||
array('-' => array($mock_image))); | array('-' => array($mock_image->getPHID()))); | ||||
} | } | ||||
} | } | ||||
if (!$errors) { | if (!$errors) { | ||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; | $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; | ||||
$xactions[] = id(new PholioTransaction()) | $xactions[] = id(new PholioTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ||||
->setMetadataValue('edge:type', $proj_edge_type) | ->setMetadataValue('edge:type', $proj_edge_type) | ||||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |