Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14015039
D18862.id45251.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D18862.id45251.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 4, 12:29 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6729025
Default Alt Text
D18862.id45251.diff (3 KB)
Attached To
Mode
D18862: Provide a generic transaction-oriented bulk job worker
Attached
Detach File
Event Timeline
Log In to Comment