Page MenuHomePhabricator

D18862.diff
No OneTemporary

D18862.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2729,6 +2729,7 @@
'PhabricatorEdgesDestructionEngineExtension' => 'infrastructure/edges/engineextension/PhabricatorEdgesDestructionEngineExtension.php',
'PhabricatorEditEngine' => 'applications/transactions/editengine/PhabricatorEditEngine.php',
'PhabricatorEditEngineAPIMethod' => 'applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php',
+ 'PhabricatorEditEngineBulkJobType' => 'applications/transactions/bulk/PhabricatorEditEngineBulkJobType.php',
'PhabricatorEditEngineCheckboxesCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineCheckboxesCommentAction.php',
'PhabricatorEditEngineColumnsCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineColumnsCommentAction.php',
'PhabricatorEditEngineCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineCommentAction.php',
@@ -8110,6 +8111,7 @@
'PhabricatorPolicyInterface',
),
'PhabricatorEditEngineAPIMethod' => 'ConduitAPIMethod',
+ 'PhabricatorEditEngineBulkJobType' => 'PhabricatorWorkerBulkJobType',
'PhabricatorEditEngineCheckboxesCommentAction' => 'PhabricatorEditEngineCommentAction',
'PhabricatorEditEngineColumnsCommentAction' => 'PhabricatorEditEngineCommentAction',
'PhabricatorEditEngineCommentAction' => 'Phobject',
diff --git a/src/applications/transactions/bulk/PhabricatorEditEngineBulkJobType.php b/src/applications/transactions/bulk/PhabricatorEditEngineBulkJobType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/bulk/PhabricatorEditEngineBulkJobType.php
@@ -0,0 +1,82 @@
+<?php
+
+final class PhabricatorEditEngineBulkJobType
+ extends PhabricatorWorkerBulkJobType {
+
+ public function getBulkJobTypeKey() {
+ return 'transaction.edit';
+ }
+
+ public function getJobName(PhabricatorWorkerBulkJob $job) {
+ return pht('Bulk Edit');
+ }
+
+ public function getDescriptionForConfirm(PhabricatorWorkerBulkJob $job) {
+ return pht(
+ 'You are about to apply a bulk edit which will affect '.
+ '%s object(s).',
+ new PhutilNumber($job->getSize()));
+ }
+
+ public function getJobSize(PhabricatorWorkerBulkJob $job) {
+ return count($job->getParameter('objectPHIDs', array()));
+ }
+
+ public function getDoneURI(PhabricatorWorkerBulkJob $job) {
+ return $job->getParameter('doneURI');
+ }
+
+ public function createTasks(PhabricatorWorkerBulkJob $job) {
+ $tasks = array();
+
+ foreach ($job->getParameter('objectPHIDs', array()) as $phid) {
+ $tasks[] = PhabricatorWorkerBulkTask::initializeNewTask($job, $phid);
+ }
+
+ return $tasks;
+ }
+
+ public function runTask(
+ PhabricatorUser $actor,
+ PhabricatorWorkerBulkJob $job,
+ PhabricatorWorkerBulkTask $task) {
+
+ $object = id(new PhabricatorObjectQuery())
+ ->setViewer($actor)
+ ->withPHIDs(array($task->getObjectPHID()))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$object) {
+ return;
+ }
+
+ $raw_xactions = $job->getParameter('xactions');
+ $xactions = $this->buildTransactions($object, $raw_xactions);
+
+ $editor = $object->getApplicationTransactionEditor()
+ ->setActor($actor)
+ ->setContentSource($job->newContentSource())
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($object, $xactions);
+ }
+
+ private function buildTransactions($object, array $raw_xactions) {
+ $xactions = array();
+
+ foreach ($raw_xactions as $raw_xaction) {
+ $xaction = $object->getApplicationTransactionTemplate()
+ ->setTransactionType($raw_xaction['type'])
+ ->setNewValue($raw_xaction['value']);
+
+ $xactions[] = $xaction;
+ }
+
+ return $xactions;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 3:33 AM (19 h, 56 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6729025
Default Alt Text
D18862.diff (3 KB)

Event Timeline