From 14dc274e9e3568a276c654b0845252019525fb6f Mon Sep 17 00:00:00 2001 From: javiexin Date: Thu, 16 Jul 2015 10:47:04 +0200 Subject: [PATCH] [ticket/14387] Extend avatar-driver by extension in ACP not possible Create a driver method to provide the driver config name, and use it within the manager method. Default driver config name is the same as now. But new drivers are able to override the config name with their own. PHPBB3-14387 --- phpBB/phpbb/avatar/driver/driver.php | 8 ++++++++ phpBB/phpbb/avatar/driver/driver_interface.php | 7 +++++++ phpBB/phpbb/avatar/manager.php | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php index b3ced7edf7..a23b626e50 100644 --- a/phpBB/phpbb/avatar/driver/driver.php +++ b/phpBB/phpbb/avatar/driver/driver.php @@ -119,6 +119,14 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface return $this->name; } + /** + * {@inheritdoc} + */ + public function get_config_name() + { + return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this)); + } + /** * Sets the name of the driver. * diff --git a/phpBB/phpbb/avatar/driver/driver_interface.php b/phpBB/phpbb/avatar/driver/driver_interface.php index 835609745a..d984717d74 100644 --- a/phpBB/phpbb/avatar/driver/driver_interface.php +++ b/phpBB/phpbb/avatar/driver/driver_interface.php @@ -25,6 +25,13 @@ interface driver_interface */ public function get_name(); + /** + * Returns the config name of the driver. To be used in accessing the CONFIG variables. + * + * @return string Config name of driver. + */ + public function get_config_name(); + /** * Get the avatar url and dimensions * diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index 8d83152ed6..5274ac6a26 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -276,7 +276,7 @@ class manager */ public function get_driver_config_name($driver) { - return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($driver)); + return $driver->get_config_name(); } /**