mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-09 02:06:32 +02:00
[ticket/11857] Use passed service collection instead of container in manager
The service collection that was already passed to the avatar manager should be used in the avatar manager method get_driver() instead of the container itself. PHPBB3-11857
This commit is contained in:
@@ -22,7 +22,6 @@ services:
|
||||
arguments:
|
||||
- @config
|
||||
- @avatar.driver_collection
|
||||
- @service_container
|
||||
|
||||
cache:
|
||||
class: phpbb\cache\service
|
||||
|
@@ -41,12 +41,6 @@ class manager
|
||||
*/
|
||||
protected $avatar_drivers;
|
||||
|
||||
/**
|
||||
* Service container object
|
||||
* @var object
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Default avatar data row
|
||||
* @var array
|
||||
@@ -63,13 +57,27 @@ class manager
|
||||
*
|
||||
* @param \phpbb\config\config $config phpBB configuration
|
||||
* @param array $avatar_drivers Avatar drivers passed via the service container
|
||||
* @param object $container Container object
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, $avatar_drivers, $container)
|
||||
public function __construct(\phpbb\config\config $config, $avatar_drivers)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->avatar_drivers = $avatar_drivers;
|
||||
$this->container = $container;
|
||||
$this->register_avatar_drivers($avatar_drivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register avatar drivers
|
||||
*
|
||||
* @param array $avatar_drivers Service collection of avatar drivers
|
||||
*/
|
||||
protected function register_avatar_drivers($avatar_drivers)
|
||||
{
|
||||
if (!empty($avatar_drivers))
|
||||
{
|
||||
foreach ($avatar_drivers as $driver)
|
||||
{
|
||||
$this->avatar_drivers[$driver->get_name()] = $driver;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +120,7 @@ class manager
|
||||
* There is no need to handle invalid avatar types as the following code
|
||||
* will cause a ServiceNotFoundException if the type does not exist
|
||||
*/
|
||||
$driver = $this->container->get($avatar_type);
|
||||
$driver = $this->avatar_drivers[$avatar_type];
|
||||
|
||||
return $driver;
|
||||
}
|
||||
|
Reference in New Issue
Block a user