mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-08 01:36:57 +02:00
[ticket/15699] Add progress bar and use template macros
PHPBB3-15699
This commit is contained in:
@@ -15,6 +15,7 @@ namespace phpbb\storage;
|
||||
|
||||
use phpbb\config\config;
|
||||
use phpbb\di\service_collection;
|
||||
use phpbb\storage\adapter\adapter_interface;
|
||||
use phpbb\storage\exception\storage_exception;
|
||||
|
||||
class adapter_factory
|
||||
@@ -53,9 +54,24 @@ class adapter_factory
|
||||
*
|
||||
* @param string $storage_name
|
||||
*
|
||||
* @return \phpbb\storage\adapter\adapter_interface
|
||||
* @return adapter_interface
|
||||
*/
|
||||
public function get($storage_name)
|
||||
public function get(string $storage_name)
|
||||
{
|
||||
$provider_class = $this->config['storage\\' . $storage_name . '\\provider'];
|
||||
$provider = $this->providers->get_by_class($provider_class);
|
||||
|
||||
$options = [];
|
||||
foreach (array_keys($provider->get_options()) as $definition)
|
||||
{
|
||||
/** @psalm-suppress InvalidArrayOffset */
|
||||
$options[$definition] = $this->config['storage\\' . $storage_name . '\\config\\' . $definition];
|
||||
}
|
||||
|
||||
return $this->get_with_options($storage_name, $options);
|
||||
}
|
||||
|
||||
public function get_with_options(string $storage_name, array $options)
|
||||
{
|
||||
$provider_class = $this->config['storage\\' . $storage_name . '\\provider'];
|
||||
$provider = $this->providers->get_by_class($provider_class);
|
||||
@@ -66,28 +82,8 @@ class adapter_factory
|
||||
}
|
||||
|
||||
$adapter = $this->adapters->get_by_class($provider->get_adapter_class());
|
||||
$adapter->configure($this->build_options($storage_name, $provider->get_options()));
|
||||
$adapter->configure($options);
|
||||
|
||||
return $adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains configuration for a given storage
|
||||
*
|
||||
* @param string $storage_name
|
||||
* @param array $definitions
|
||||
*
|
||||
* @return array Returns storage configuration values
|
||||
*/
|
||||
public function build_options($storage_name, array $definitions)
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (array_keys($definitions) as $definition)
|
||||
{
|
||||
$options[$definition] = $this->config['storage\\' . $storage_name . '\\config\\' . $definition];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user