mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +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;
|
||||
}
|
||||
}
|
||||
|
@@ -45,12 +45,12 @@ class helper
|
||||
/**
|
||||
* Get adapter definitions from a provider
|
||||
*
|
||||
* @param string $provider Provider class
|
||||
* @param string $provider_class Provider class
|
||||
* @return array Adapter definitions
|
||||
*/
|
||||
public function get_provider_options(string $provider) : array
|
||||
public function get_provider_options(string $provider_class) : array
|
||||
{
|
||||
return $this->provider_collection->get_by_class($provider)->get_options();
|
||||
return $this->provider_collection->get_by_class($provider_class)->get_options();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,21 +108,16 @@ class helper
|
||||
|
||||
if (!isset($adapters[$storage_name]))
|
||||
{
|
||||
$provider = $this->state_helper->new_provider($storage_name);
|
||||
$provider_class = $this->provider_collection->get_by_class($provider);
|
||||
|
||||
$adapter = $this->adapter_collection->get_by_class($provider_class->get_adapter_class());
|
||||
$definitions = $this->get_provider_options($provider);
|
||||
$provider_class = $this->state_helper->new_provider($storage_name);
|
||||
$definitions = array_keys($this->get_provider_options($provider_class));
|
||||
|
||||
$options = [];
|
||||
foreach (array_keys($definitions) as $definition)
|
||||
foreach ($definitions as $definition)
|
||||
{
|
||||
$options[$definition] = $this->state_helper->new_definition_value($storage_name, $definition);
|
||||
}
|
||||
|
||||
$adapter->configure($options);
|
||||
|
||||
$adapters[$storage_name] = $adapter;
|
||||
$adapters[$storage_name] = $this->adapter_factory->get_with_options($storage_name, $options);
|
||||
}
|
||||
|
||||
return $adapters[$storage_name];
|
||||
|
@@ -37,7 +37,10 @@ class local implements provider_interface
|
||||
public function get_options()
|
||||
{
|
||||
return [
|
||||
'path' => ['type' => 'text'],
|
||||
'path' => [
|
||||
'tag' => 'input',
|
||||
'type' => 'text',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -163,6 +163,7 @@ class state_helper
|
||||
|
||||
foreach (array_keys($options) as $definition)
|
||||
{
|
||||
/** @psalm-suppress InvalidArrayOffset */
|
||||
$state['storages'][$storage_name]['config'][$definition] = $request->variable([$storage_name, $definition], '');
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ namespace phpbb\storage;
|
||||
|
||||
use phpbb\cache\driver\driver_interface as cache;
|
||||
use phpbb\db\driver\driver_interface as db;
|
||||
use phpbb\storage\adapter\adapter_interface;
|
||||
use phpbb\storage\exception\storage_exception;
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ use phpbb\storage\exception\storage_exception;
|
||||
class storage
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\storage\adapter\adapter_interface
|
||||
* @var adapter_interface
|
||||
*/
|
||||
protected $adapter;
|
||||
|
||||
@@ -39,7 +40,7 @@ class storage
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var \phpbb\storage\adapter_factory
|
||||
* @var adapter_factory
|
||||
*/
|
||||
protected $factory;
|
||||
|
||||
@@ -58,7 +59,7 @@ class storage
|
||||
*
|
||||
* @param db $db
|
||||
* @param cache $cache
|
||||
* @param \phpbb\storage\adapter_factory $factory
|
||||
* @param adapter_factory $factory
|
||||
* @param string $storage_name
|
||||
* @param string $storage_table
|
||||
*/
|
||||
@@ -84,7 +85,7 @@ class storage
|
||||
/**
|
||||
* Returns an adapter instance
|
||||
*
|
||||
* @return \phpbb\storage\adapter\adapter_interface
|
||||
* @return adapter_interface
|
||||
*/
|
||||
protected function get_adapter()
|
||||
{
|
||||
|
Reference in New Issue
Block a user