mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 20:22:46 +01:00
3a0a086a09
Summary: Ref T12738. Update sources to modular transactions. Test Plan: Created and edited a source. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12738 Differential Revision: https://secure.phabricator.com/D17994
42 lines
1 KiB
PHP
42 lines
1 KiB
PHP
<?php
|
|
|
|
final class NuanceSourceDefaultQueueTransaction
|
|
extends NuanceSourceTransactionType {
|
|
|
|
const TRANSACTIONTYPE = 'source.queue.default';
|
|
|
|
public function generateOldValue($object) {
|
|
return $object->getDefaultQueuePHID();
|
|
}
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
$object->setDefaultQueuePHID($value);
|
|
}
|
|
|
|
public function getTitle() {
|
|
return pht(
|
|
'%s changed the default queue for this source from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderOldHandle(),
|
|
$this->renderNewHandle());
|
|
}
|
|
|
|
public function validateTransactions($object, array $xactions) {
|
|
$errors = array();
|
|
|
|
if (!$object->getDefaultQueuePHID() && !$xactions) {
|
|
$errors[] = $this->newRequiredError(
|
|
pht('Sources must have a default queue.'));
|
|
}
|
|
|
|
foreach ($xactions as $xaction) {
|
|
if (!$xaction->getNewValue()) {
|
|
$errors[] = $this->newRequiredError(
|
|
pht('Sources must have a default queue.'));
|
|
}
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
|
|
}
|