private function applyTransactionEffect(PhabricatorProject $project, PhabricatorProjectTransaction $xaction)
 {
     $type = $xaction->getTransactionType();
     switch ($type) {
         case PhabricatorProjectTransactionType::TYPE_NAME:
             $project->setName($xaction->getNewValue());
             $project->setPhrictionSlug($xaction->getNewValue());
             $this->validateName($project);
             break;
         case PhabricatorProjectTransactionType::TYPE_STATUS:
             $project->setStatus($xaction->getNewValue());
             break;
         case PhabricatorProjectTransactionType::TYPE_MEMBERS:
             $old = array_fill_keys($xaction->getOldValue(), true);
             $new = array_fill_keys($xaction->getNewValue(), true);
             $this->addEdges = array_keys(array_diff_key($new, $old));
             $this->remEdges = array_keys(array_diff_key($old, $new));
             break;
         case PhabricatorProjectTransactionType::TYPE_CAN_VIEW:
             $project->setViewPolicy($xaction->getNewValue());
             break;
         case PhabricatorProjectTransactionType::TYPE_CAN_EDIT:
             $project->setEditPolicy($xaction->getNewValue());
             // You can't edit away your ability to edit the project.
             PhabricatorPolicyFilter::mustRetainCapability($this->user, $project, PhabricatorPolicyCapability::CAN_EDIT);
             break;
         case PhabricatorProjectTransactionType::TYPE_CAN_JOIN:
             $project->setJoinPolicy($xaction->getNewValue());
             break;
         default:
             throw new Exception("Unknown transaction type '{$type}'!");
     }
 }
 private function applyTransactionEffect(PhabricatorProject $project, PhabricatorProjectTransaction $xaction)
 {
     $type = $xaction->getTransactionType();
     switch ($type) {
         case PhabricatorProjectTransactionType::TYPE_NAME:
             $project->setName($xaction->getNewValue());
             $project->setPhrictionSlug($xaction->getNewValue());
             $this->validateName($project);
             break;
         case PhabricatorProjectTransactionType::TYPE_STATUS:
             $project->setStatus($xaction->getNewValue());
             break;
         case PhabricatorProjectTransactionType::TYPE_MEMBERS:
             $old = array_fill_keys($xaction->getOldValue(), true);
             $new = array_fill_keys($xaction->getNewValue(), true);
             $add = array();
             $rem = array();
             foreach ($project->getAffiliations() as $affil) {
                 if (empty($new[$affil->getUserPHID()])) {
                     $rem[] = $affil;
                 }
             }
             foreach ($new as $phid => $ignored) {
                 if (empty($old[$phid])) {
                     $affil = new PhabricatorProjectAffiliation();
                     $affil->setRole('');
                     $affil->setUserPHID($phid);
                     $add[] = $affil;
                 }
             }
             $this->addAffiliations = $add;
             $this->remAffiliations = $rem;
             break;
         default:
             throw new Exception("Unknown transaction type '{$type}'!");
     }
 }