@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 83 lines 2.7 kB view raw
1<?php 2 3/** 4 * Abstract "Before Destruction Engine", 5 * to fire a hook before something is permamently destroyed. 6 * 7 * This class is to be considered unstable and may receive variations 8 * over time. If you want to use this engine or extend its features, please 9 * share your use-case here, even if the task is closed: 10 * https://we.phorge.it/T16079 11 */ 12abstract class PhabricatorBeforeDestructionEngineExtension extends Phobject { 13 14 /** 15 * Get the extension internal key. 16 * 17 * @return string 18 */ 19 final public function getExtensionKey(): string { 20 return $this->getPhobjectClassConstant('EXTENSIONKEY'); 21 } 22 23 /** 24 * Get the extension human name. 25 * 26 * @return string 27 */ 28 abstract public function getExtensionName(): string; 29 30 /** 31 * Check if this extension supports a "Before Destruction" hook 32 * on the specified object. 33 * 34 * The object is guaranteed to have a PHID and still exist but 35 * will be destroyed later. 36 * This method should not contain write operations. 37 * This method exposes a PhabricatorDestructionEngine since it can give 38 * useful info, but here you should not use it to destroy objects. 39 * When this method returns true, the method beforeDestroyObject() 40 * will be fired. 41 * 42 * @param PhabricatorDestructionEngine $destruction_engine 43 * Available destruction engine 44 * @param object $object 45 * Object that will be destroyed 46 * @return bool If true, beforeDestroyObject() 47 * will be fired. 48 */ 49 public function canBeforeDestroyObject( 50 PhabricatorDestructionEngine $destruction_engine, 51 $object): bool { 52 return true; 53 } 54 55 /** 56 * Call your "Before Destruction" hook on the specified object. 57 * The object is guaranteed to have a PHID and still exist but 58 * will be destroyed later. 59 * This method is not called if canBeforeDestroyObject() returns false. 60 * 61 * @param PhabricatorDestructionEngine $destruction_engine 62 * Available destruction engine 63 * @param object $object 64 * Object that will be destroyed 65 */ 66 abstract public function beforeDestroyObject( 67 PhabricatorDestructionEngine $destruction_engine, 68 $object): void; 69 70 /** 71 * Get all "Before Destruction Engine" extensions. 72 * 73 * @return list<PhabricatorDestructionEngineExtension> 74 */ 75 final public static function getAllExtensions(): array { 76 $map = new PhutilClassMapQuery(); 77 return $map 78 ->setAncestorClass(self::class) 79 ->setUniqueMethod('getExtensionKey') 80 ->execute(); 81 } 82 83}