diff options
author | Andreas Fischer <bantu@phpbb.com> | 2013-10-21 11:04:23 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2013-10-21 11:04:23 +0200 |
commit | ba5b53521a186dc23d6d4b849c7f76196c783d43 (patch) | |
tree | 0881bc85252172f371c3d1112f4a3e53ca781551 | |
parent | 4649155f415310a67be409ff15a3140accbae799 (diff) | |
parent | a80d5c93e354aa1e4dff548a89129ccd7f5488ee (diff) | |
download | forums-ba5b53521a186dc23d6d4b849c7f76196c783d43.tar forums-ba5b53521a186dc23d6d4b849c7f76196c783d43.tar.gz forums-ba5b53521a186dc23d6d4b849c7f76196c783d43.tar.bz2 forums-ba5b53521a186dc23d6d4b849c7f76196c783d43.tar.xz forums-ba5b53521a186dc23d6d4b849c7f76196c783d43.zip |
Merge remote-tracking branch 'marc1706/ticket/11930' into develop
* marc1706/ticket/11930:
[ticket/11930] Update docblock of avatar driver constructor
[ticket/11930] Modify order of properties to fit constructor method
[ticket/11930] Move path_helper in front of optional cache argument
[ticket/11930] Fix tests after adding phpbb\path_helper to avatar drivers
[ticket/11930] Use \phpbb\path_helper for avatar URLs
-rw-r--r-- | phpBB/config/avatars.yml | 4 | ||||
-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-- | tests/avatar/manager_test.php | 12 |
5 files changed, 25 insertions, 5 deletions
diff --git a/phpBB/config/avatars.yml b/phpBB/config/avatars.yml index 31ae1ecef9..d22a5db2ae 100644 --- a/phpBB/config/avatars.yml +++ b/phpBB/config/avatars.yml @@ -5,6 +5,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.gravatar]] @@ -17,6 +18,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.local]] @@ -29,6 +31,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.remote]] @@ -41,6 +44,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.upload]] 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/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index ba1fb04b33..4afa594beb 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -25,9 +25,17 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase $config = new \phpbb\config\config(array()); $request = $this->getMock('\phpbb\request\request'); $cache = $this->getMock('\phpbb\cache\driver\driver_interface'); + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $this->phpbb_root_path, + $this->phpEx + ); // $this->avatar_foobar will be needed later on - $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); + $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache)); $this->avatar_foobar->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.foobar')); @@ -40,7 +48,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase foreach ($this->avatar_drivers() as $driver) { - $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); + $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache)); $cur_avatar->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.' . $driver)); |