Add legacy backend storage functionality

This commit is contained in:
nupplaPhil 2020-01-17 23:25:11 +01:00
parent 3e72e8015b
commit ca8ca05051
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
2 changed files with 55 additions and 1 deletions

View file

@ -88,6 +88,9 @@ class StorageManager
*/
public function getByName(string $name = null, $onlyUserBackend = false)
{
// @todo 2020.09 Remove this call after 2 releases
$name = $this->checkLegacyBackend($name);
// If there's no cached instance create a new instance
if (!isset($this->backendInstances[$name])) {
// If the current name isn't a valid backend (or the SystemResource instance) create it
@ -140,6 +143,25 @@ class StorageManager
(!$onlyUserBackend && $name === Storage\SystemResource::getName());
}
/**
* Check for legacy backend storage class names (= full model class name)
*
* @todo 2020.09 Remove this function after 2 releases, because there shouldn't be any legacy backend classes left
*
* @param string|null $name a potential, legacy storage name ("Friendica\Model\Storage\...")
*
* @return string|null The current storage name
*/
private function checkLegacyBackend(string $name = null)
{
if (stristr($name, 'Friendica\Model\Storage\\')) {
$this->logger->notice('Using deprecated storage class value', ['name' => $name]);
return substr($name, 24);
}
return $name;
}
/**
* @brief Set current storage backend class
*