protected function applyCustomInternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     $v = $xaction->getNewValue();
     switch ($xaction->getTransactionType()) {
         case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
             return $object->setIsEnabled($v);
         case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
             return $object->setShouldAllowRegistration($v);
         case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
             return $object->setShouldAllowLink($v);
         case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
             return $object->setShouldAllowUnlink($v);
         case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
             return $object->setShouldTrustEmails($v);
         case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
             $key = $xaction->getMetadataValue(PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
             return $object->setProperty($key, $v);
     }
 }
 protected function applyCustomInternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
     $status_revision = ArcanistDifferentialRevisionStatus::NEEDS_REVISION;
     $status_plan = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED;
     $status_abandoned = ArcanistDifferentialRevisionStatus::ABANDONED;
     $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
     switch ($xaction->getTransactionType()) {
         case DifferentialTransaction::TYPE_INLINE:
             return;
         case DifferentialTransaction::TYPE_UPDATE:
             if (!$this->getIsCloseByCommit()) {
                 switch ($object->getStatus()) {
                     case $status_revision:
                     case $status_plan:
                     case $status_abandoned:
                         $object->setStatus($status_review);
                         break;
                 }
             }
             $diff = $this->requireDiff($xaction->getNewValue());
             $object->setLineCount($diff->getLineCount());
             if ($this->repositoryPHIDOverride !== false) {
                 $object->setRepositoryPHID($this->repositoryPHIDOverride);
             } else {
                 $object->setRepositoryPHID($diff->getRepositoryPHID());
             }
             $object->attachActiveDiff($diff);
             // TODO: Update the `diffPHID` once we add that.
             return;
         case DifferentialTransaction::TYPE_ACTION:
             switch ($xaction->getNewValue()) {
                 case DifferentialAction::ACTION_RESIGN:
                 case DifferentialAction::ACTION_ACCEPT:
                 case DifferentialAction::ACTION_REJECT:
                     // These have no direct effects, and affect review status only
                     // indirectly by altering reviewers with TYPE_EDGE transactions.
                     return;
                 case DifferentialAction::ACTION_ABANDON:
                     $object->setStatus(ArcanistDifferentialRevisionStatus::ABANDONED);
                     return;
                 case DifferentialAction::ACTION_RETHINK:
                     $object->setStatus($status_plan);
                     return;
                 case DifferentialAction::ACTION_RECLAIM:
                     $object->setStatus($status_review);
                     return;
                 case DifferentialAction::ACTION_REOPEN:
                     $object->setStatus($status_review);
                     return;
                 case DifferentialAction::ACTION_REQUEST:
                     $object->setStatus($status_review);
                     return;
                 case DifferentialAction::ACTION_CLOSE:
                     $old_status = $object->getStatus();
                     $object->setStatus(ArcanistDifferentialRevisionStatus::CLOSED);
                     $was_accepted = $old_status == $status_accepted;
                     $object->setProperty(DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED, $was_accepted);
                     return;
                 case DifferentialAction::ACTION_CLAIM:
                     $object->setAuthorPHID($this->getActingAsPHID());
                     return;
                 default:
                     throw new Exception(pht('Differential action "%s" is not a valid action!', $xaction->getNewValue()));
             }
             break;
     }
     return parent::applyCustomInternalTransaction($object, $xaction);
 }
 protected function applyCustomInternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case ManiphestTransaction::TYPE_PRIORITY:
             return $object->setPriority($xaction->getNewValue());
         case ManiphestTransaction::TYPE_STATUS:
             return $object->setStatus($xaction->getNewValue());
         case ManiphestTransaction::TYPE_TITLE:
             return $object->setTitle($xaction->getNewValue());
         case ManiphestTransaction::TYPE_DESCRIPTION:
             return $object->setDescription($xaction->getNewValue());
         case ManiphestTransaction::TYPE_OWNER:
             $phid = $xaction->getNewValue();
             // Update the "ownerOrdering" column to contain the full name of the
             // owner, if the task is assigned.
             $handle = null;
             if ($phid) {
                 $handle = id(new PhabricatorHandleQuery())->setViewer($this->getActor())->withPHIDs(array($phid))->executeOne();
             }
             if ($handle) {
                 $object->setOwnerOrdering($handle->getName());
             } else {
                 $object->setOwnerOrdering(null);
             }
             return $object->setOwnerPHID($phid);
         case ManiphestTransaction::TYPE_SUBPRIORITY:
             $object->setSubpriority($xaction->getNewValue());
             return;
         case ManiphestTransaction::TYPE_MERGED_INTO:
             $object->setStatus(ManiphestTaskStatus::getDuplicateStatus());
             return;
         case ManiphestTransaction::TYPE_COVER_IMAGE:
             $file_phid = $xaction->getNewValue();
             if ($file_phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($this->getActor())->withPHIDs(array($file_phid))->executeOne();
             } else {
                 $file = null;
             }
             if (!$file || !$file->isTransformableImage()) {
                 $object->setProperty('cover.filePHID', null);
                 $object->setProperty('cover.thumbnailPHID', null);
                 return;
             }
             $xform_key = PhabricatorFileThumbnailTransform::TRANSFORM_WORKCARD;
             $xform = PhabricatorFileTransform::getTransformByKey($xform_key)->executeTransform($file);
             $object->setProperty('cover.filePHID', $file->getPHID());
             $object->setProperty('cover.thumbnailPHID', $xform->getPHID());
             return;
         case ManiphestTransaction::TYPE_POINTS:
             $object->setPoints($xaction->getNewValue());
             return;
         case ManiphestTransaction::TYPE_MERGED_FROM:
         case ManiphestTransaction::TYPE_PARENT:
         case PhabricatorTransactions::TYPE_COLUMNS:
             return;
     }
 }