From b89539a70e1fa315b944a0e711208db170ebf079 Mon Sep 17 00:00:00 2001 From: javiexin Date: Fri, 19 Jun 2015 12:46:25 +0200 Subject: [PATCH] [ticket/13867] Enable/disable mechanism for new profile field types Adds methods to enable, disable and purge profile field types to the profilefields\manager class. These methods are to be called from extensions that add new profile field types on the enable, disable and purge methods of the ext class. If not done, any profile field of a new type that is left after extension is disabled or removed will break the forum in several places. Remove dependency from container, add dependencies with specific classes. Change try/catch by !isset. PHPBB3-13867 --- .../container/services_profilefield.yml | 3 +- phpBB/phpbb/profilefields/manager.php | 35 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/phpBB/config/default/container/services_profilefield.yml b/phpBB/config/default/container/services_profilefield.yml index 8b519e5c7c..968a54ee79 100644 --- a/phpBB/config/default/container/services_profilefield.yml +++ b/phpBB/config/default/container/services_profilefield.yml @@ -2,14 +2,15 @@ services: profilefields.manager: class: phpbb\profilefields\manager arguments: - - '@service_container' - '@auth' - '@dbal.conn' + - '@dbal.tools' - '@dispatcher' - '@request' - '@template' - '@profilefields.type_collection' - '@user' + - '@config_text' - '%tables.profile_fields%' - '%tables.profile_fields_language%' - '%tables.profile_fields_data%' diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index bb76d39f85..a7ce59aeb1 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -13,19 +13,11 @@ namespace phpbb\profilefields; -use Symfony\Component\DependencyInjection\ContainerInterface; - /** * Custom Profile Fields */ class manager { - /** - * Container interface - * @var ContainerInterface - */ - protected $container; - /** * Auth object * @var \phpbb\auth\auth @@ -38,6 +30,12 @@ class manager */ protected $db; + /** + * Database tools object + * @var \phpbb\db\tools + */ + protected $db_tools; + /** * Event dispatcher object * @var \phpbb\event\dispatcher_interface @@ -68,6 +66,12 @@ class manager */ protected $user; + /** + * Config_text object + * @var \phpbb\config\db_text + */ + protected $config_text; + protected $fields_table; protected $fields_language_table; @@ -76,42 +80,37 @@ class manager protected $profile_cache = array(); - protected $config_text; - - protected $db_tools; - /** * Construct * - * @param ContainerInterface $container A container * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\db\driver\driver_interface $db Database object + * @param \phpbb\db\tools $db_tools Database object * @param \phpbb\event\dispatcher_interface $dispatcher Event dispatcher object * @param \phpbb\request\request $request Request object * @param \phpbb\template\template $template Template object * @param \phpbb\di\service_collection $type_collection * @param \phpbb\user $user User object + * @param \phpbb\config\db_text $config_text Config_text object * @param string $fields_table * @param string $fields_language_table * @param string $fields_data_table */ - public function __construct(ContainerInterface $container, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, \phpbb\config\db_text $config_text, $fields_table, $fields_language_table, $fields_data_table) { - $this->container = $container; $this->auth = $auth; $this->db = $db; + $this->db_tools = $db_tools; $this->dispatcher = $dispatcher; $this->request = $request; $this->template = $template; $this->type_collection = $type_collection; $this->user = $user; + $this->config_text = $config_text; $this->fields_table = $fields_table; $this->fields_language_table = $fields_language_table; $this->fields_data_table = $fields_data_table; - - $this->config_text = $this->container->get('config_text'); - $this->db_tools = $this->container->get('dbal.tools'); } /**