mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-12 03:34:04 +02:00
[ticket/11201] Remove dependency from types on the manager
PHPBB3-11201
This commit is contained in:
@@ -39,6 +39,12 @@ class manager
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Service Collection object
|
||||
* @var \phpbb\di\service_collection
|
||||
*/
|
||||
protected $type_collection;
|
||||
|
||||
/**
|
||||
* User object
|
||||
* @var \phpbb\user
|
||||
@@ -60,17 +66,19 @@ class manager
|
||||
* @param \phpbb\db\driver\driver $db Database 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 string $fields_table
|
||||
* @param string $fields_language_table
|
||||
* @param string $fields_data_table
|
||||
*/
|
||||
public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table)
|
||||
public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver $db, \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)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->db = $db;
|
||||
$this->request = $request;
|
||||
$this->template = $template;
|
||||
$this->type_collection = $type_collection;
|
||||
$this->user = $user;
|
||||
|
||||
$this->fields_table = $fields_table;
|
||||
@@ -78,20 +86,6 @@ class manager
|
||||
$this->fields_data_table = $fields_data_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the type collection
|
||||
*
|
||||
* We need to set the type collection later,
|
||||
* in order to avoid a circular dependency
|
||||
*
|
||||
* @param \phpbb\di\service_collection $type_collection
|
||||
* @return null
|
||||
*/
|
||||
public function set_type_collection(\phpbb\di\service_collection $type_collection)
|
||||
{
|
||||
$this->type_collection = $type_collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign editable fields to template, mode can be profile (for profile change) or register (for registration)
|
||||
* Called by ucp_profile and ucp_register
|
||||
@@ -131,8 +125,8 @@ class manager
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
// Return templated field
|
||||
$tpl_snippet = $this->process_field_row('change', $row);
|
||||
$profile_field = $this->type_collection[$row['field_type']];
|
||||
$tpl_snippet = $profile_field->process_field_row('change', $row);
|
||||
|
||||
$this->template->assign_block_vars('profile_fields', array(
|
||||
'LANG_NAME' => $this->user->lang($row['lang_name']),
|
||||
@@ -351,33 +345,6 @@ class manager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Templated value/field. Possible values for $mode are:
|
||||
* change == user is able to set/enter profile values; preview == just show the value
|
||||
*/
|
||||
public function process_field_row($mode, $profile_row)
|
||||
{
|
||||
$preview_options = ($mode == 'preview') ? $this->vars['lang_options'] : false;
|
||||
|
||||
// set template filename
|
||||
$this->template->set_filenames(array(
|
||||
'cp_body' => 'custom_profile_fields.html',
|
||||
));
|
||||
|
||||
// empty previously filled blockvars
|
||||
foreach ($this->type_collection as $field_key => $field_type)
|
||||
{
|
||||
$this->template->destroy_block_vars($field_type->get_name_short());
|
||||
}
|
||||
|
||||
// Assign template variables
|
||||
$profile_field = $this->type_collection[$profile_row['field_type']];
|
||||
$profile_field->generate_field($profile_row, $preview_options);
|
||||
|
||||
// Return templated data
|
||||
return $this->template->assign_display('cp_body');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build Array for user insertion into custom profile fields table
|
||||
*/
|
||||
|
Reference in New Issue
Block a user