mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Move property transaction construction to Almanac
Summary: Ref T7627. This centralizes this transaction construction code so the unit tests and Instances can both use it. Test Plan: See D12116. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7627 Differential Revision: https://secure.phabricator.com/D12118
This commit is contained in:
parent
6eadfe6a6f
commit
c7178b7e7b
1 changed files with 34 additions and 0 deletions
|
@ -31,6 +31,40 @@ final class AlmanacProperty
|
|||
return $this;
|
||||
}
|
||||
|
||||
public static function buildTransactions(
|
||||
AlmanacPropertyInterface $object,
|
||||
array $properties) {
|
||||
|
||||
$template = $object->getApplicationTransactionTemplate();
|
||||
|
||||
$attached_properties = $object->getAlmanacProperties();
|
||||
foreach ($properties as $key => $value) {
|
||||
if (empty($attached_properties[$key])) {
|
||||
$attached_properties[] = id(new AlmanacProperty())
|
||||
->setObjectPHID($object->getPHID())
|
||||
->setFieldName($key);
|
||||
}
|
||||
}
|
||||
$object->attachAlmanacProperties($attached_properties);
|
||||
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
$object,
|
||||
PhabricatorCustomField::ROLE_DEFAULT);
|
||||
$fields = $field_list->getFields();
|
||||
|
||||
$xactions = array();
|
||||
foreach ($properties as $name => $property) {
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)
|
||||
->setMetadataValue('customfield:key', $name)
|
||||
->setOldValue($object->getAlmanacPropertyValue($name))
|
||||
->setNewValue($property);
|
||||
}
|
||||
|
||||
return $xactions;
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue