public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $handle_data = new PhabricatorObjectHandleData(array($this->phid));
     $handles = $handle_data->loadHandles();
     $handle = $handles[$this->phid];
     $object_type = $handle->getType();
     $attach_type = $this->type;
     $objects = $handle_data->loadObjects();
     $object = idx($objects, $this->phid);
     if (!$object) {
         return new Aphront404Response();
     }
     if ($request->isFormPost()) {
         $phids = explode(';', $request->getStr('phids'));
         $phids = array_filter($phids);
         $phids = array_values($phids);
         switch ($this->action) {
             case self::ACTION_MERGE:
                 return $this->performMerge($object, $handle, $phids);
             case self::ACTION_DEPENDENCIES:
             case self::ACTION_ATTACH:
                 $two_way = true;
                 if ($this->action == self::ACTION_DEPENDENCIES) {
                     $two_way = false;
                     $this->detectGraphCycles($object, $attach_type, $phids);
                 }
                 $editor = new PhabricatorObjectAttachmentEditor($object_type, $object);
                 $editor->setUser($this->getRequest()->getUser());
                 $editor->attachObjects($attach_type, $phids, $two_way);
                 return id(new AphrontReloadResponse())->setURI($handle->getURI());
             default:
                 throw new Exception("Unsupported attach action.");
         }
     } else {
         switch ($this->action) {
             case self::ACTION_ATTACH:
             case self::ACTION_DEPENDENCIES:
                 $phids = $object->getAttachedPHIDs($attach_type);
                 break;
             default:
                 $phids = array();
                 break;
         }
     }
     $strings = $this->getStrings();
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $obj_dialog = new PhabricatorObjectSelectorDialog();
     $obj_dialog->setUser($user)->setHandles($handles)->setFilters(array('assigned' => 'Assigned to Me', 'created' => 'Created By Me', 'open' => 'All Open ' . $strings['target_plural_noun'], 'all' => 'All ' . $strings['target_plural_noun']))->setSelectedFilter($strings['selected'])->setCancelURI($handle->getURI())->setSearchURI('/search/select/' . $attach_type . '/')->setTitle($strings['title'])->setHeader($strings['header'])->setButtonText($strings['button'])->setInstructions($strings['instructions']);
     $dialog = $obj_dialog->buildDialog();
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 /**
  * Attach the revision to the task(s) and the task(s) to the revision.
  *
  * @return void
  */
 public function didWriteRevision(DifferentialRevisionEditor $editor)
 {
     $aeditor = new PhabricatorObjectAttachmentEditor(PhabricatorPHIDConstants::PHID_TYPE_DREV, $editor->getRevision());
     $aeditor->setUser($this->getUser());
     $aeditor->attachObjects(PhabricatorPHIDConstants::PHID_TYPE_TASK, $this->maniphestTasks, $two_way = true);
 }