Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / applications / system / codex / PhabricatorDestructibleCodex.php
blob1c37907c34337c9ef0f9f3a2f941a3bfb742124d
1 <?php
3 abstract class PhabricatorDestructibleCodex
4 extends Phobject {
6 private $viewer;
7 private $object;
9 public function getDestructionNotes() {
10 return array();
13 final public function setViewer(PhabricatorUser $viewer) {
14 $this->viewer = $viewer;
15 return $this;
18 final public function getViewer() {
19 return $this->viewer;
22 final public function setObject(
23 PhabricatorDestructibleCodexInterface $object) {
24 $this->object = $object;
25 return $this;
28 final public function getObject() {
29 return $this->object;
32 final public static function newFromObject(
33 PhabricatorDestructibleCodexInterface $object,
34 PhabricatorUser $viewer) {
36 if (!($object instanceof PhabricatorDestructibleInterface)) {
37 throw new Exception(
38 pht(
39 'Object (of class "%s") implements interface "%s", but must also '.
40 'implement interface "%s".',
41 get_class($object),
42 'PhabricatorDestructibleCodexInterface',
43 'PhabricatorDestructibleInterface'));
46 $codex = $object->newDestructibleCodex();
47 if (!($codex instanceof PhabricatorDestructibleCodex)) {
48 throw new Exception(
49 pht(
50 'Object (of class "%s") implements interface "%s", but defines '.
51 'method "%s" incorrectly: this method must return an object of '.
52 'class "%s".',
53 get_class($object),
54 'PhabricatorDestructibleCodexInterface',
55 'newDestructibleCodex()',
56 __CLASS__));
59 $codex
60 ->setObject($object)
61 ->setViewer($viewer);
63 return $codex;