diff options
Diffstat (limited to 'apps/files_external/lib/identifiertrait.php')
-rw-r--r-- | apps/files_external/lib/identifiertrait.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/files_external/lib/identifiertrait.php b/apps/files_external/lib/identifiertrait.php index 139911580fc..7f36144e474 100644 --- a/apps/files_external/lib/identifiertrait.php +++ b/apps/files_external/lib/identifiertrait.php @@ -23,6 +23,7 @@ namespace OCA\Files_External\Lib; /** * Trait for objects requiring an identifier (and/or identifier aliases) + * Also supports deprecation to a different object, linking the objects */ trait IdentifierTrait { @@ -32,6 +33,9 @@ trait IdentifierTrait { /** @var string[] */ protected $identifierAliases = []; + /** @var IdentifierTrait */ + protected $deprecateTo = null; + /** * @return string */ @@ -65,4 +69,34 @@ trait IdentifierTrait { return $this; } + /** + * @return object|null + */ + public function getDeprecateTo() { + return $this->deprecateTo; + } + + /** + * @param object $destinationObject + * @return self + */ + public function deprecateTo($destinationObject) { + $this->deprecateTo = $destinationObject; + return $this; + } + + /** + * @return array + */ + public function jsonSerializeIdentifier() { + $data = [ + 'identifier' => $this->identifier, + 'identifierAliases' => $this->identifierAliases, + ]; + if ($this->deprecateTo) { + $data['deprecateTo'] = $this->deprecateTo->getIdentifier(); + } + return $data; + } + } |