@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3abstract class PhabricatorDestructibleCodex
4 extends Phobject {
5
6 private $viewer;
7 private $object;
8
9 public function getDestructionNotes() {
10 return array();
11 }
12
13 final public function setViewer(PhabricatorUser $viewer) {
14 $this->viewer = $viewer;
15 return $this;
16 }
17
18 final public function getViewer() {
19 return $this->viewer;
20 }
21
22 final public function setObject(
23 PhabricatorDestructibleCodexInterface $object) {
24 $this->object = $object;
25 return $this;
26 }
27
28 final public function getObject() {
29 return $this->object;
30 }
31
32 final public static function newFromObject(
33 PhabricatorDestructibleCodexInterface $object,
34 PhabricatorUser $viewer) {
35
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'));
44 }
45
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 self::class));
57 }
58
59 $codex
60 ->setObject($object)
61 ->setViewer($viewer);
62
63 return $codex;
64 }
65
66}