diff options
author | Matt Friedman <maf675@gmail.com> | 2013-10-29 19:12:32 -0700 |
---|---|---|
committer | Matt Friedman <maf675@gmail.com> | 2013-10-29 19:12:32 -0700 |
commit | 16213c92fe71cb1029bdac3b797529c6c74f6e96 (patch) | |
tree | 2256b3b880d113b814cd8c8b42b415dd407f0ef1 /phpBB/phpbb/avatar | |
parent | 67beb97efec06c4a663c7eec8d54ab3194744f83 (diff) | |
parent | 2f1cf0d287f416f1c3b388d5d3e68d897f226aaf (diff) | |
download | forums-16213c92fe71cb1029bdac3b797529c6c74f6e96.tar forums-16213c92fe71cb1029bdac3b797529c6c74f6e96.tar.gz forums-16213c92fe71cb1029bdac3b797529c6c74f6e96.tar.bz2 forums-16213c92fe71cb1029bdac3b797529c6c74f6e96.tar.xz forums-16213c92fe71cb1029bdac3b797529c6c74f6e96.zip |
[ticket/11935] Merge remote-tracking branch 'upstream/develop'
PHPBB3-11935
Diffstat (limited to 'phpBB/phpbb/avatar')
-rw-r--r-- | phpBB/phpbb/avatar/driver/driver.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/local.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/upload.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/manager.php | 30 |
4 files changed, 30 insertions, 14 deletions
diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php index 0c54951cbd..206df86543 100644 --- a/phpBB/phpbb/avatar/driver/driver.php +++ b/phpBB/phpbb/avatar/driver/driver.php @@ -48,6 +48,12 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface protected $php_ext; /** + * Path Helper + * @var \phpbb\path_helper + */ + protected $path_helper; + + /** * Cache driver * @var \phpbb\cache\driver\driver_interface */ @@ -75,13 +81,15 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface * @param \phpbb\request\request $request Request object * @param string $phpbb_root_path Path to the phpBB root * @param string $php_ext PHP file extension + * @param \phpbb_path_helper $path_helper phpBB path helper * @param \phpbb\cache\driver\driver_interface $cache Cache driver */ - public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\cache\driver\driver_interface $cache = null) + public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null) { $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $this->path_helper = $path_helper; $this->cache = $cache; } diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index d779099c46..0686ffe79a 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -29,7 +29,7 @@ class local extends \phpbb\avatar\driver\driver public function get_data($row) { return array( - 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], + 'src' => $this->path_helper->get_web_root_path() . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], 'width' => $row['avatar_width'], 'height' => $row['avatar_height'], ); diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 377c9a0b04..bda872df7a 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -29,7 +29,7 @@ class upload extends \phpbb\avatar\driver\driver public function get_data($row, $ignore_config = false) { return array( - 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'], + 'src' => $this->path_helper->get_web_root_path() . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'], 'width' => $row['avatar_width'], 'height' => $row['avatar_height'], ); diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index c28380a401..7c26bce5ae 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -42,12 +42,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; } |