Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngine.php
| Show First 20 Lines • Show All 1,019 Lines • ▼ Show 20 Lines | private function buildCommentResponse($object) { | ||||
| $is_preview = $request->isPreviewRequest(); | $is_preview = $request->isPreviewRequest(); | ||||
| $view_uri = $this->getObjectViewURI($object); | $view_uri = $this->getObjectViewURI($object); | ||||
| $template = $object->getApplicationTransactionTemplate(); | $template = $object->getApplicationTransactionTemplate(); | ||||
| $comment_template = $template->getApplicationTransactionCommentObject(); | $comment_template = $template->getApplicationTransactionCommentObject(); | ||||
| $comment_text = $request->getStr('comment'); | $comment_text = $request->getStr('comment'); | ||||
| $actions = $request->getStr('editengine.actions'); | |||||
| if ($actions) { | |||||
| $actions = phutil_json_decode($actions); | |||||
| } | |||||
| if ($is_preview) { | if ($is_preview) { | ||||
| $version_key = PhabricatorVersionedDraft::KEY_VERSION; | $version_key = PhabricatorVersionedDraft::KEY_VERSION; | ||||
| $request_version = $request->getInt($version_key); | $request_version = $request->getInt($version_key); | ||||
| $current_version = $this->loadDraftVersion($object); | $current_version = $this->loadDraftVersion($object); | ||||
| if ($request_version >= $current_version) { | if ($request_version >= $current_version) { | ||||
| $draft = PhabricatorVersionedDraft::loadOrCreateDraft( | $draft = PhabricatorVersionedDraft::loadOrCreateDraft( | ||||
| $object->getPHID(), | $object->getPHID(), | ||||
| $viewer->getPHID(), | $viewer->getPHID(), | ||||
| $current_version); | $current_version); | ||||
| // TODO: This is just a proof of concept. | // TODO: This is just a proof of concept. | ||||
| $draft->setProperty('temporary.comment', $comment_text); | $draft | ||||
| $draft->save(); | ->setProperty('temporary.comment', $comment_text) | ||||
| ->setProperty('actions', $actions) | |||||
| ->save(); | |||||
| } | } | ||||
| } | } | ||||
| $xactions = array(); | $xactions = array(); | ||||
| $actions = $request->getStr('editengine.actions'); | |||||
| if ($actions) { | if ($actions) { | ||||
| $type_map = array(); | $type_map = array(); | ||||
| foreach ($fields as $field) { | foreach ($fields as $field) { | ||||
| $types = $field->getCommentEditTypes(); | $types = $field->getCommentEditTypes(); | ||||
| foreach ($types as $type) { | foreach ($types as $type) { | ||||
| $type_map[$type->getEditType()] = array( | $type_map[$type->getEditType()] = array( | ||||
| 'type' => $type, | 'type' => $type, | ||||
| 'field' => $field, | 'field' => $field, | ||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||
| $actions = phutil_json_decode($actions); | |||||
| foreach ($actions as $action) { | foreach ($actions as $action) { | ||||
| $type = idx($action, 'type'); | $type = idx($action, 'type'); | ||||
| if (!$type) { | if (!$type) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $spec = idx($type_map, $type); | $spec = idx($type_map, $type); | ||||
| if (!$spec) { | if (!$spec) { | ||||
| ▲ Show 20 Lines • Show All 273 Lines • Show Last 20 Lines | |||||