diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-17 16:40:56 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-09-23 12:10:02 +0200 |
commit | 060d16961596b24a2d0cf9e30408482ce33cefe6 (patch) | |
tree | f2914e4ed2bde08c0fe68ccd82bce137396140f2 /apps/files_external/lib | |
parent | 38a260e963abd04b75aff8d67a8cf7b3b20a9c67 (diff) | |
download | nextcloud-server-060d16961596b24a2d0cf9e30408482ce33cefe6.tar.gz nextcloud-server-060d16961596b24a2d0cf9e30408482ce33cefe6.zip |
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.
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/auth/authmechanism.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/backend/backend.php | 1 | ||||
-rw-r--r-- | apps/files_external/lib/identifiertrait.php | 34 |
3 files changed, 37 insertions, 0 deletions
diff --git a/apps/files_external/lib/auth/authmechanism.php b/apps/files_external/lib/auth/authmechanism.php index 11d99bb330d..2ab34ed0105 100644 --- a/apps/files_external/lib/auth/authmechanism.php +++ b/apps/files_external/lib/auth/authmechanism.php @@ -92,6 +92,8 @@ class AuthMechanism implements \JsonSerializable { */ public function jsonSerialize() { $data = $this->jsonSerializeDefinition(); + $data += $this->jsonSerializeIdentifier(); + $data['scheme'] = $this->getScheme(); return $data; diff --git a/apps/files_external/lib/backend/backend.php b/apps/files_external/lib/backend/backend.php index 90d5d38ed94..68585cf377e 100644 --- a/apps/files_external/lib/backend/backend.php +++ b/apps/files_external/lib/backend/backend.php @@ -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(); 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; + } + } |