mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
[ticket/15699] Fixes code review
PHPBB3-15699
This commit is contained in:
@@ -21,31 +21,41 @@ class helper
|
||||
/** @var config */
|
||||
protected $config;
|
||||
|
||||
/** @var service_collection */
|
||||
protected $provider_collection;
|
||||
|
||||
/** @var service_collection */
|
||||
protected $adapter_collection;
|
||||
|
||||
/** @var adapter_factory */
|
||||
protected $adapter_factory;
|
||||
|
||||
/** @var state_helper */
|
||||
protected $state_helper;
|
||||
|
||||
public function __construct(config $config, service_collection $provider_collection, service_collection $adapter_collection, adapter_factory $adapter_factory, state_helper $state_helper)
|
||||
/** @var service_collection */
|
||||
protected $provider_collection;
|
||||
|
||||
/** @var service_collection */
|
||||
protected $adapter_collection;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $config
|
||||
* @param adapter_factory $adapter_factory
|
||||
* @param state_helper $state_helper
|
||||
* @param service_collection $provider_collection
|
||||
* @param service_collection $adapter_collection
|
||||
*/
|
||||
public function __construct(config $config, adapter_factory $adapter_factory, state_helper $state_helper, service_collection $provider_collection, service_collection $adapter_collection)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->provider_collection = $provider_collection;
|
||||
$this->adapter_collection = $adapter_collection;
|
||||
$this->adapter_factory = $adapter_factory;
|
||||
$this->state_helper = $state_helper;
|
||||
$this->provider_collection = $provider_collection;
|
||||
$this->adapter_collection = $adapter_collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get adapter definitions from a provider
|
||||
*
|
||||
* @param string $provider_class Provider class
|
||||
*
|
||||
* @return array Adapter definitions
|
||||
*/
|
||||
public function get_provider_options(string $provider_class) : array
|
||||
@@ -57,6 +67,7 @@ class helper
|
||||
* Get the current provider from config
|
||||
*
|
||||
* @param string $storage_name Storage name
|
||||
*
|
||||
* @return string The current provider
|
||||
*/
|
||||
public function get_current_provider(string $storage_name) : string
|
||||
@@ -69,6 +80,7 @@ class helper
|
||||
*
|
||||
* @param string $storage_name Storage name
|
||||
* @param string $definition Definition
|
||||
*
|
||||
* @return string Definition value
|
||||
*/
|
||||
public function get_current_definition(string $storage_name, string $definition) : string
|
||||
@@ -102,7 +114,7 @@ class helper
|
||||
*
|
||||
* @return mixed Storage adapter instance
|
||||
*/
|
||||
public function get_new_adapter(string $storage_name)
|
||||
public function get_new_adapter(string $storage_name): mixed
|
||||
{
|
||||
static $adapters = [];
|
||||
|
||||
@@ -123,6 +135,13 @@ class helper
|
||||
return $adapters[$storage_name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete configuration options for a given storage
|
||||
*
|
||||
* @param string $storage_name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete_storage_options(string $storage_name): void
|
||||
{
|
||||
$provider = $this->get_current_provider($storage_name);
|
||||
@@ -134,16 +153,41 @@ class helper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a provider in configuration for a given storage
|
||||
*
|
||||
* @param string $storage_name
|
||||
* @param string $provider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_storage_provider(string $storage_name, string $provider): void
|
||||
{
|
||||
$this->config->set('storage\\' . $storage_name . '\\provider', $provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set storage options in configuration for a given storage
|
||||
*
|
||||
* @param string $storage_name
|
||||
* @param string $definition
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_storage_definition(string $storage_name, string $definition, string $value): void
|
||||
{
|
||||
$this->config->set('storage\\' . $storage_name . '\\config\\' . $definition, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file from the current adapter to the new adapter
|
||||
*
|
||||
* @param $storage_name
|
||||
* @param $file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function copy_file_to_new_adapter($storage_name, $file): void
|
||||
{
|
||||
$current_adapter = $this->get_current_adapter($storage_name);
|
||||
@@ -166,7 +210,6 @@ class helper
|
||||
*/
|
||||
public function update_storage_config(string $storage_name) : void
|
||||
{
|
||||
|
||||
// Remove old storage config
|
||||
$this->delete_storage_options($storage_name);
|
||||
|
||||
|
Reference in New Issue
Block a user