mirror of
https://github.com/nextcloud/server.git
synced 2024-08-05 08:15:54 +02:00
Add deprecation mechanic to IdentifierTrait
Deprecation allows a backend/auth mechanism to designate an object that it deprecates to, allowing clean transitions to updated codebases.
This commit is contained in:
parent
38a260e963
commit
060d169615
@ -92,6 +92,8 @@ class AuthMechanism implements \JsonSerializable {
|
||||
*/
|
||||
public function jsonSerialize() {
|
||||
$data = $this->jsonSerializeDefinition();
|
||||
$data += $this->jsonSerializeIdentifier();
|
||||
|
||||
$data['scheme'] = $this->getScheme();
|
||||
|
||||
return $data;
|
||||
|
@ -142,6 +142,7 @@ class Backend implements \JsonSerializable {
|
||||
*/
|
||||
public function jsonSerialize() {
|
||||
$data = $this->jsonSerializeDefinition();
|
||||
$data += $this->jsonSerializeIdentifier();
|
||||
|
||||
$data['backend'] = $data['name']; // legacy compat
|
||||
$data['priority'] = $this->getPriority();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user