1
0
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:
Marc Alexander
2013-10-27 09:52:09 +01:00
parent b0e0834637
commit b2f638b793
3 changed files with 21 additions and 14 deletions

View File

@@ -22,7 +22,6 @@ services:
arguments:
- @config
- @avatar.driver_collection
- @service_container
cache:
class: phpbb\cache\service

View File

@@ -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;
}