Differential D14863 Diff 35930 src/applications/project/editor/PhabricatorProjectTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/editor/PhabricatorProjectTransactionEditor.php
Show All 21 Lines | public function getTransactionTypes() { | ||||
$types[] = PhabricatorProjectTransaction::TYPE_NAME; | $types[] = PhabricatorProjectTransaction::TYPE_NAME; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_SLUGS; | $types[] = PhabricatorProjectTransaction::TYPE_SLUGS; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_STATUS; | $types[] = PhabricatorProjectTransaction::TYPE_STATUS; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_IMAGE; | $types[] = PhabricatorProjectTransaction::TYPE_IMAGE; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_ICON; | $types[] = PhabricatorProjectTransaction::TYPE_ICON; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_COLOR; | $types[] = PhabricatorProjectTransaction::TYPE_COLOR; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_LOCKED; | $types[] = PhabricatorProjectTransaction::TYPE_LOCKED; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_PARENT; | $types[] = PhabricatorProjectTransaction::TYPE_PARENT; | ||||
$types[] = PhabricatorProjectTransaction::TYPE_MILESTONE; | |||||
return $types; | return $types; | ||||
} | } | ||||
protected function getCustomTransactionOldValue( | protected function getCustomTransactionOldValue( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
Show All 11 Lines | switch ($xaction->getTransactionType()) { | ||||
return $object->getProfileImagePHID(); | return $object->getProfileImagePHID(); | ||||
case PhabricatorProjectTransaction::TYPE_ICON: | case PhabricatorProjectTransaction::TYPE_ICON: | ||||
return $object->getIcon(); | return $object->getIcon(); | ||||
case PhabricatorProjectTransaction::TYPE_COLOR: | case PhabricatorProjectTransaction::TYPE_COLOR: | ||||
return $object->getColor(); | return $object->getColor(); | ||||
case PhabricatorProjectTransaction::TYPE_LOCKED: | case PhabricatorProjectTransaction::TYPE_LOCKED: | ||||
return (int)$object->getIsMembershipLocked(); | return (int)$object->getIsMembershipLocked(); | ||||
case PhabricatorProjectTransaction::TYPE_PARENT: | case PhabricatorProjectTransaction::TYPE_PARENT: | ||||
case PhabricatorProjectTransaction::TYPE_MILESTONE: | |||||
return null; | return null; | ||||
} | } | ||||
return parent::getCustomTransactionOldValue($object, $xaction); | return parent::getCustomTransactionOldValue($object, $xaction); | ||||
} | } | ||||
protected function getCustomTransactionNewValue( | protected function getCustomTransactionNewValue( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
case PhabricatorProjectTransaction::TYPE_NAME: | case PhabricatorProjectTransaction::TYPE_NAME: | ||||
case PhabricatorProjectTransaction::TYPE_SLUGS: | case PhabricatorProjectTransaction::TYPE_SLUGS: | ||||
case PhabricatorProjectTransaction::TYPE_STATUS: | case PhabricatorProjectTransaction::TYPE_STATUS: | ||||
case PhabricatorProjectTransaction::TYPE_IMAGE: | case PhabricatorProjectTransaction::TYPE_IMAGE: | ||||
case PhabricatorProjectTransaction::TYPE_ICON: | case PhabricatorProjectTransaction::TYPE_ICON: | ||||
case PhabricatorProjectTransaction::TYPE_COLOR: | case PhabricatorProjectTransaction::TYPE_COLOR: | ||||
case PhabricatorProjectTransaction::TYPE_LOCKED: | case PhabricatorProjectTransaction::TYPE_LOCKED: | ||||
case PhabricatorProjectTransaction::TYPE_PARENT: | case PhabricatorProjectTransaction::TYPE_PARENT: | ||||
return $xaction->getNewValue(); | return $xaction->getNewValue(); | ||||
case PhabricatorProjectTransaction::TYPE_MILESTONE: | |||||
$current = queryfx_one( | |||||
$object->establishConnection('w'), | |||||
'SELECT MAX(milestoneNumber) n | |||||
FROM %T | |||||
WHERE parentProjectPHID = %s', | |||||
$object->getTableName(), | |||||
$object->getParentProject()->getPHID()); | |||||
if (!$current) { | |||||
$number = 1; | |||||
} else { | |||||
$number = (int)$current['n'] + 1; | |||||
} | |||||
return $number; | |||||
} | } | ||||
return parent::getCustomTransactionNewValue($object, $xaction); | return parent::getCustomTransactionNewValue($object, $xaction); | ||||
} | } | ||||
protected function applyCustomInternalTransaction( | protected function applyCustomInternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
Show All 19 Lines | switch ($xaction->getTransactionType()) { | ||||
$object->setColor($xaction->getNewValue()); | $object->setColor($xaction->getNewValue()); | ||||
return; | return; | ||||
case PhabricatorProjectTransaction::TYPE_LOCKED: | case PhabricatorProjectTransaction::TYPE_LOCKED: | ||||
$object->setIsMembershipLocked($xaction->getNewValue()); | $object->setIsMembershipLocked($xaction->getNewValue()); | ||||
return; | return; | ||||
case PhabricatorProjectTransaction::TYPE_PARENT: | case PhabricatorProjectTransaction::TYPE_PARENT: | ||||
$object->setParentProjectPHID($xaction->getNewValue()); | $object->setParentProjectPHID($xaction->getNewValue()); | ||||
return; | return; | ||||
case PhabricatorProjectTransaction::TYPE_MILESTONE: | |||||
$object->setMilestoneNumber($xaction->getNewValue()); | |||||
return; | |||||
} | } | ||||
return parent::applyCustomInternalTransaction($object, $xaction); | return parent::applyCustomInternalTransaction($object, $xaction); | ||||
} | } | ||||
protected function applyCustomExternalTransaction( | protected function applyCustomExternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
Show All 36 Lines | switch ($xaction->getTransactionType()) { | ||||
return; | return; | ||||
case PhabricatorProjectTransaction::TYPE_STATUS: | case PhabricatorProjectTransaction::TYPE_STATUS: | ||||
case PhabricatorProjectTransaction::TYPE_IMAGE: | case PhabricatorProjectTransaction::TYPE_IMAGE: | ||||
case PhabricatorProjectTransaction::TYPE_ICON: | case PhabricatorProjectTransaction::TYPE_ICON: | ||||
case PhabricatorProjectTransaction::TYPE_COLOR: | case PhabricatorProjectTransaction::TYPE_COLOR: | ||||
case PhabricatorProjectTransaction::TYPE_LOCKED: | case PhabricatorProjectTransaction::TYPE_LOCKED: | ||||
case PhabricatorProjectTransaction::TYPE_PARENT: | case PhabricatorProjectTransaction::TYPE_PARENT: | ||||
case PhabricatorProjectTransaction::TYPE_MILESTONE: | |||||
return; | return; | ||||
} | } | ||||
return parent::applyCustomExternalTransaction($object, $xaction); | return parent::applyCustomExternalTransaction($object, $xaction); | ||||
} | } | ||||
protected function applyBuiltinExternalTransaction( | protected function applyBuiltinExternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
▲ Show 20 Lines • Show All 413 Lines • ▼ Show 20 Lines | if ($slug_object) { | ||||
return; | return; | ||||
} | } | ||||
$new_slug = id(new PhabricatorProjectSlug()) | $new_slug = id(new PhabricatorProjectSlug()) | ||||
->setSlug($slug) | ->setSlug($slug) | ||||
->setProjectPHID($object->getPHID()) | ->setProjectPHID($object->getPHID()) | ||||
->save(); | ->save(); | ||||
} | } | ||||
protected function applyFinalEffects( | |||||
PhabricatorLiskDAO $object, | |||||
array $xactions) { | |||||
$materialize = false; | |||||
foreach ($xactions as $xaction) { | |||||
switch ($xaction->getTransactionType()) { | |||||
case PhabricatorTransactions::TYPE_EDGE: | |||||
switch ($xaction->getMetadataValue('edge:type')) { | |||||
case PhabricatorProjectProjectHasMemberEdgeType::EDGECONST: | |||||
$materialize = true; | |||||
break; | |||||
} | |||||
break; | |||||
case PhabricatorProjectTransaction::TYPE_PARENT: | |||||
$materialize = true; | |||||
break; | |||||
} | |||||
} | |||||
if ($materialize) { | |||||
id(new PhabricatorProjectsMembershipIndexEngineExtension()) | |||||
->rematerialize($object); | |||||
} | |||||
return parent::applyFinalEffects($object, $xactions); | |||||
} | |||||
} | } |