mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
[ticket/11201] Use a service collection for the types instead of the container
PHPBB3-11201
This commit is contained in:
parent
5df7f76e6b
commit
7fd5f16fa2
@ -4,11 +4,11 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- @auth
|
- @auth
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @service_container
|
|
||||||
#- @profilefields.type_collection
|
|
||||||
- @request
|
- @request
|
||||||
- @template
|
- @template
|
||||||
- @user
|
- @user
|
||||||
|
calls:
|
||||||
|
- [set_type_collection, [@profilefields.type_collection]]
|
||||||
|
|
||||||
profilefields.lang_helper:
|
profilefields.lang_helper:
|
||||||
class: \phpbb\profilefields\lang_helper
|
class: \phpbb\profilefields\lang_helper
|
||||||
|
@ -21,16 +21,29 @@ class profilefields
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct($auth, $db, /** @todo: */ $phpbb_container, $request, $template, $user)
|
public function __construct($auth, $db, $request, $template, $user)
|
||||||
{
|
{
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->container = $phpbb_container;
|
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
* Assign editable fields to template, mode can be profile (for profile change) or register (for registration)
|
||||||
* Called by ucp_profile and ucp_register
|
* Called by ucp_profile and ucp_register
|
||||||
@ -69,9 +82,10 @@ class profilefields
|
|||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Return templated field
|
// Return templated field
|
||||||
$tpl_snippet = $this->process_field_row('change', $row);
|
$tpl_snippet = $this->process_field_row('change', $row);
|
||||||
$profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$row['field_type']]);
|
$profile_field = $this->type_collection['profilefields.type.' . $this->profile_types[$row['field_type']]];
|
||||||
|
|
||||||
$this->template->assign_block_vars('profile_fields', array(
|
$this->template->assign_block_vars('profile_fields', array(
|
||||||
'LANG_NAME' => $row['lang_name'],
|
'LANG_NAME' => $row['lang_name'],
|
||||||
@ -146,7 +160,7 @@ class profilefields
|
|||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$row['field_type']]);
|
$profile_field = $this->type_collection['profilefields.type.' . $this->profile_types[$row['field_type']]];
|
||||||
$cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row);
|
$cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row);
|
||||||
$check_value = $cp_data['pf_' . $row['field_ident']];
|
$check_value = $cp_data['pf_' . $row['field_ident']];
|
||||||
|
|
||||||
@ -286,7 +300,7 @@ class profilefields
|
|||||||
|
|
||||||
foreach ($profile_row as $ident => $ident_ary)
|
foreach ($profile_row as $ident => $ident_ary)
|
||||||
{
|
{
|
||||||
$profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$row['field_type']]);
|
$profile_field = $this->type_collection['profilefields.type.' . $this->profile_types[$row['field_type']]];
|
||||||
$value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
|
$value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
|
||||||
|
|
||||||
if ($value === NULL)
|
if ($value === NULL)
|
||||||
@ -341,7 +355,7 @@ class profilefields
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assign template variables
|
// Assign template variables
|
||||||
$profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$profile_row['field_type']]);
|
$profile_field = $this->type_collection['profilefields.type.' . $this->profile_types[$profile_row['field_type']]];
|
||||||
$profile_field->generate_field($profile_row, $preview_options);
|
$profile_field->generate_field($profile_row, $preview_options);
|
||||||
|
|
||||||
// Return templated data
|
// Return templated data
|
||||||
@ -368,7 +382,7 @@ class profilefields
|
|||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$row['field_type']]);
|
$profile_field = $this->type_collection['profilefields.type.' . $this->profile_types[$row['field_type']]];
|
||||||
$cp_data['pf_' . $row['field_ident']] = $profile_field->get_default_field_value($row);
|
$cp_data['pf_' . $row['field_ident']] = $profile_field->get_default_field_value($row);
|
||||||
}
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user