phorge/src/applications/system/codex/PhabricatorDestructibleCodex.php
epriestley ab018e1b49 When destorying a repository, print a notification about removing the working copy
Summary:
Fixes T12946. `bin/remove destroy` does not remove working copies: it's more dangerous than usual, and we can't do it in the general (clustered) case.

Print a notification message after destroying a repository.

Test Plan:
  - Destroyed a repository, got a hint about the working copy.
  - Destroyed a task, things worked normally.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12946

Differential Revision: https://secure.phabricator.com/D18313
2017-08-01 08:57:39 -07:00

67 lines
1.6 KiB
PHP

<?php
abstract class PhabricatorDestructibleCodex
extends Phobject {
private $viewer;
private $object;
public function getDestructionNotes() {
return array();
}
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
final public function getViewer() {
return $this->viewer;
}
final public function setObject(
PhabricatorDestructibleCodexInterface $object) {
$this->object = $object;
return $this;
}
final public function getObject() {
return $this->object;
}
final public static function newFromObject(
PhabricatorDestructibleCodexInterface $object,
PhabricatorUser $viewer) {
if (!($object instanceof PhabricatorDestructibleInterface)) {
throw new Exception(
pht(
'Object (of class "%s") implements interface "%s", but must also '.
'implement interface "%s".',
get_class($object),
'PhabricatorDestructibleCodexInterface',
'PhabricatorDestructibleInterface'));
}
$codex = $object->newDestructibleCodex();
if (!($codex instanceof PhabricatorDestructibleCodex)) {
throw new Exception(
pht(
'Object (of class "%s") implements interface "%s", but defines '.
'method "%s" incorrectly: this method must return an object of '.
'class "%s".',
get_class($object),
'PhabricatorDestructibleCodexInterface',
'newDestructibleCodex()',
__CLASS__));
}
$codex
->setObject($object)
->setViewer($viewer);
return $codex;
}
}