1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-19 07:08:09 +01:00

[feature/passwords] Use dependency injection for passwords driver helper

The passwords driver helper is now injected into the driver base instead
of being manually loaded.

PHPBB3-11610
This commit is contained in:
Marc Alexander 2013-09-22 22:53:10 +02:00
parent f5eb0d744e
commit 01512104b5
4 changed files with 14 additions and 17 deletions

View File

@ -6,6 +6,7 @@ services:
class: phpbb_passwords_driver_bcrypt
arguments:
- @config
- @passwords.driver_helper
calls:
- [set_name, [passwords.driver.bcrypt]]
tags:
@ -15,6 +16,7 @@ services:
class: phpbb_passwords_driver_bcrypt_2y
arguments:
- @config
- @passwords.driver_helper
calls:
- [set_name, [passwords.driver.bcrypt_2y]]
tags:
@ -24,6 +26,7 @@ services:
class: phpbb_passwords_driver_salted_md5
arguments:
- @config
- @passwords.driver_helper
calls:
- [set_name, [passwords.driver.salted_md5]]
tags:
@ -33,6 +36,7 @@ services:
class: phpbb_passwords_driver_phpass
arguments:
- @config
- @passwords.driver_helper
calls:
- [set_name, [passwords.driver.phpass]]
tags:
@ -45,6 +49,9 @@ services:
tags:
- { name: service_collection, tag: passwords.driver }
passwords.driver_helper:
class: phpbb_passwords_driver_helper
passwords.manager:
class: phpbb_passwords_manager
arguments:

View File

@ -34,10 +34,10 @@ abstract class phpbb_passwords_driver_base implements phpbb_passwords_driver_int
*
* @return string Hash prefix
*/
public function __construct(phpbb_config $config)
public function __construct(phpbb_config $config, phpbb_passwords_driver_helper $helper)
{
$this->config = $config;
$this->helper = new phpbb_passwords_driver_helper($this);
$this->helper = $helper;
}
/**

View File

@ -20,23 +20,12 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_passwords_driver_helper
{
/** @var phpbb_config */
protected $driver;
/**
* base64 alphabet
* @var string
*/
public $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
/**
* Constructor of passwords driver helper object
*/
public function __construct($driver)
{
$this->driver = $driver;
}
/**
* Base64 encode hash
*

View File

@ -26,12 +26,13 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase
// Prepare dependencies for manager and driver
$config = new phpbb_config(array());
$driver_helper = new phpbb_passwords_driver_helper;
$this->passwords_drivers = array(
'passwords.driver.bcrypt' => new phpbb_passwords_driver_bcrypt($config),
'passwords.driver.bcrypt_2y' => new phpbb_passwords_driver_bcrypt_2y($config),
'passwords.driver.salted_md5' => new phpbb_passwords_driver_salted_md5($config),
'passwords.driver.phpass' => new phpbb_passwords_driver_phpass($config),
'passwords.driver.bcrypt' => new phpbb_passwords_driver_bcrypt($config, $driver_helper),
'passwords.driver.bcrypt_2y' => new phpbb_passwords_driver_bcrypt_2y($config, $driver_helper),
'passwords.driver.salted_md5' => new phpbb_passwords_driver_salted_md5($config, $driver_helper),
'passwords.driver.phpass' => new phpbb_passwords_driver_phpass($config, $driver_helper),
);
foreach ($this->passwords_drivers as $key => $driver)