Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / xaction / PhabricatorRepositoryActivateTransaction.php
blob31298c55aad92b9ab2c6c27b46075ec48ab6780d
1 <?php
3 final class PhabricatorRepositoryActivateTransaction
4 extends PhabricatorRepositoryTransactionType {
6 const TRANSACTIONTYPE = 'repo:activate';
8 public function generateOldValue($object) {
9 return $object->isTracked();
12 public function applyInternalEffects($object, $value) {
13 // The first time a repository is activated, clear the "new repository"
14 // flag so we stop showing setup hints.
15 if ($value) {
16 $object->setDetail('newly-initialized', false);
19 $object->setDetail('tracking-enabled', $value);
22 public function getTitle() {
23 $new = $this->getNewValue();
25 // TODO: Old versions of this transaction use a boolean value, but
26 // should be migrated.
27 $is_deactivate =
28 (!$new) ||
29 ($new == PhabricatorRepository::STATUS_INACTIVE);
31 if (!$is_deactivate) {
32 return pht(
33 '%s activated this repository.',
34 $this->renderAuthor());
35 } else {
36 return pht(
37 '%s deactivated this repository.',
38 $this->renderAuthor());
42 public function validateTransactions($object, array $xactions) {
43 $errors = array();
45 $status_map = PhabricatorRepository::getStatusMap();
46 foreach ($xactions as $xaction) {
47 $status = $xaction->getNewValue();
48 if (empty($status_map[$status])) {
49 $errors[] = $this->newInvalidError(
50 pht(
51 'Repository status "%s" is not valid. Valid statuses are: %s.',
52 $status,
53 implode(', ', array_keys($status_map))),
54 $xaction);
58 return $errors;