3 final class PhabricatorRepositoryBlueprintsTransaction
4 extends PhabricatorRepositoryTransactionType
{
6 const TRANSACTIONTYPE
= 'repo:automation-blueprints';
8 public function generateOldValue($object) {
9 return $object->getDetail('automation.blueprintPHIDs', array());
12 public function applyInternalEffects($object, $value) {
13 $object->setDetail('automation.blueprintPHIDs', $value);
16 public function applyExternalEffects($object, $value) {
17 DrydockAuthorization
::applyAuthorizationChanges(
21 $this->getNewValue());
24 public function getTitle() {
25 $old = $this->getOldValue();
26 $new = $this->getNewValue();
28 $add = array_diff($new, $old);
29 $rem = array_diff($old, $new);
33 '%s changed %s automation blueprint(s), '.
34 'added %s: %s; removed %s: %s.',
35 $this->renderAuthor(),
36 new PhutilNumber(count($add) +
count($rem)),
37 new PhutilNumber(count($add)),
38 $this->renderHandleList($add),
39 new PhutilNumber(count($rem)),
40 $this->renderHandleList($rem));
43 '%s added %s automation blueprint(s): %s.',
44 $this->renderAuthor(),
45 new PhutilNumber(count($add)),
46 $this->renderHandleList($add));
49 '%s removed %s automation blueprint(s): %s.',
50 $this->renderAuthor(),
51 new PhutilNumber(count($rem)),
52 $this->renderHandleList($rem));
56 public function validateTransactions($object, array $xactions) {
59 foreach ($xactions as $xaction) {
60 $old = nonempty($xaction->getOldValue(), array());
61 $new = nonempty($xaction->getNewValue(), array());
63 $add = array_diff($new, $old);
65 $invalid = PhabricatorObjectQuery
::loadInvalidPHIDsForViewer(
69 $errors[] = $this->newInvalidError(
71 'Some of the selected automation blueprints are invalid '.
73 implode(', ', $invalid)),