public final function buildEditEngineCommentView($object) { $config = $this->loadEditEngineConfiguration(null); $viewer = $this->getViewer(); $object_phid = $object->getPHID(); $header_text = $this->getCommentViewHeaderText($object); $button_text = $this->getCommentViewButtonText($object); $comment_uri = $this->getEditURI($object, 'comment/'); $view = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($object_phid)->setHeaderText($header_text)->setAction($comment_uri)->setSubmitButtonName($button_text); $draft = PhabricatorVersionedDraft::loadDraft($object_phid, $viewer->getPHID()); if ($draft) { $view->setVersionedDraft($draft); } $view->setCurrentVersion($this->loadDraftVersion($object)); $fields = $this->buildEditFields($object); $all_types = array(); foreach ($fields as $field) { // TODO: Load draft stuff. $types = $field->getCommentEditTypes(); foreach ($types as $type) { $all_types[] = $type; } } $view->setEditTypes($all_types); return $view; }
public final function buildEditEngineCommentView($object) { $config = $this->loadDefaultEditConfiguration(); if (!$config) { // TODO: This just nukes the entire comment form if you don't have access // to any edit forms. We might want to tailor this UX a bit. return id(new PhabricatorApplicationTransactionCommentView())->setNoPermission(true); } $viewer = $this->getViewer(); $object_phid = $object->getPHID(); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); if ($is_serious) { $header_text = $this->getCommentViewSeriousHeaderText($object); $button_text = $this->getCommentViewSeriousButtonText($object); } else { $header_text = $this->getCommentViewHeaderText($object); $button_text = $this->getCommentViewButtonText($object); } $comment_uri = $this->getEditURI($object, 'comment/'); $view = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($object_phid)->setHeaderText($header_text)->setAction($comment_uri)->setSubmitButtonName($button_text); $draft = PhabricatorVersionedDraft::loadDraft($object_phid, $viewer->getPHID()); if ($draft) { $view->setVersionedDraft($draft); } $view->setCurrentVersion($this->loadDraftVersion($object)); $fields = $this->buildEditFields($object); $comment_actions = array(); foreach ($fields as $field) { if (!$field->shouldGenerateTransactionsFromComment()) { continue; } $comment_action = $field->getCommentAction(); if (!$comment_action) { continue; } $key = $comment_action->getKey(); // TODO: Validate these better. $comment_actions[$key] = $comment_action; } $view->setCommentActions($comment_actions); return $view; }
public final function buildEditEngineCommentView($object) { $config = $this->loadDefaultEditConfiguration(); if (!$config) { // TODO: This just nukes the entire comment form if you don't have access // to any edit forms. We might want to tailor this UX a bit. return id(new PhabricatorApplicationTransactionCommentView())->setNoPermission(true); } $viewer = $this->getViewer(); $object_phid = $object->getPHID(); $header_text = $this->getCommentViewHeaderText($object); $button_text = $this->getCommentViewButtonText($object); $comment_uri = $this->getEditURI($object, 'comment/'); $view = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($object_phid)->setHeaderText($header_text)->setAction($comment_uri)->setSubmitButtonName($button_text); $draft = PhabricatorVersionedDraft::loadDraft($object_phid, $viewer->getPHID()); if ($draft) { $view->setVersionedDraft($draft); } $view->setCurrentVersion($this->loadDraftVersion($object)); $fields = $this->buildEditFields($object); $all_types = array(); foreach ($fields as $field) { if (!$this->isCommentField($field)) { continue; } $types = $field->getCommentEditTypes(); foreach ($types as $type) { $all_types[] = $type; } } $view->setEditTypes($all_types); return $view; }