class manager

Properties

protected config $config

phpBB configuration

protected dispatcher_interface $phpbb_dispatcher

phpBB event dispatcher

static protected array|bool $enabled_drivers

Array that contains a list of enabled drivers

protected array $avatar_drivers

Array that contains all available avatar drivers which are passed via the service container

static protected array $default_row

Default avatar data row

Methods

__construct(config $config, dispatcher_interface $phpbb_dispatcher, array $avatar_drivers)

Construct an avatar manager object

register_avatar_drivers(array $avatar_drivers)

Register avatar drivers

object
get_driver(string $avatar_type, bool $load_enabled = true)

Get the driver object specified by the avatar type

load_enabled_drivers()

Load the list of enabled drivers This is executed once and fills self::$enabled_drivers

array
get_all_drivers()

Get a list of all avatar drivers

array
get_enabled_drivers()

Get a list of enabled avatar drivers

static array
clean_row(array $row, string $prefix = '')

Strip out user, group, or other prefixes from array keys

static string
clean_driver_name(string $name)

Clean driver names that are returned from template files Underscores are replaced with dots

static string
prepare_driver_name(string $name)

Prepare driver names for use in template files Dots are replaced with underscores

bool
is_enabled(object $driver)

Check if avatar is enabled

array
get_avatar_settings(object $driver)

Get the settings array for enabling/disabling an avatar driver

array
localize_errors(user $user, array $error)

Replace "error" strings with their real, localized form

null
handle_avatar_delete(driver_interface $db, user $user, array $avatar_data, string $table, string $prefix)

Handle deleting avatars

array
prefix_avatar_columns(string $prefix, array $data)

Prefix avatar columns

Details

at line 61
__construct(config $config, dispatcher_interface $phpbb_dispatcher, array $avatar_drivers)

Construct an avatar manager object

Parameters

config $config

phpBB configuration

dispatcher_interface $phpbb_dispatcher

phpBB event dispatcher

array $avatar_drivers

Avatar drivers passed via the service container

at line 73
protected register_avatar_drivers(array $avatar_drivers)

Register avatar drivers

Parameters

array $avatar_drivers

Service collection of avatar drivers

at line 92
object get_driver(string $avatar_type, bool $load_enabled = true)

Get the driver object specified by the avatar type

Parameters

string $avatar_type

Avatar type; by default an avatar's service container name

bool $load_enabled

Load only enabled avatars

Return Value

object

Avatar driver object

at line 131
protected load_enabled_drivers()

Load the list of enabled drivers This is executed once and fills self::$enabled_drivers

at line 156
array get_all_drivers()

Get a list of all avatar drivers

As this function will only be called in the ACP avatar settings page, it doesn't make much sense to cache the list of all avatar drivers like the list of the enabled drivers.

Return Value

array

Array containing a list of all avatar drivers

at line 177
array get_enabled_drivers()

Get a list of enabled avatar drivers

Return Value

array

Array containing a list of the enabled avatar drivers

at line 197
static array clean_row(array $row, string $prefix = '')

Strip out user, group, or other prefixes from array keys

Parameters

array $row

User data or group data

string $prefix

Prefix of data keys (e.g. user), should not include the trailing underscore

Return Value

array

User or group data with keys that have been stripped from the preceding "user" or "group" Also the group id is prefixed with g, when the prefix group is removed.

at line 228
static string clean_driver_name(string $name)

Clean driver names that are returned from template files Underscores are replaced with dots

Parameters

string $name

Driver name

Return Value

string

Cleaned driver name

at line 241
static string prepare_driver_name(string $name)

Prepare driver names for use in template files Dots are replaced with underscores

Parameters

string $name

Clean driver name

Return Value

string

Prepared driver name

at line 253
bool is_enabled(object $driver)

Check if avatar is enabled

Parameters

object $driver

Avatar driver object

Return Value

bool

True if avatar is enabled, false if it's disabled

at line 267
array get_avatar_settings(object $driver)

Get the settings array for enabling/disabling an avatar driver

Parameters

object $driver

Avatar driver object

Return Value

array

Array of configuration options as consumed by acp_board

at line 287
array localize_errors(user $user, array $error)

Replace "error" strings with their real, localized form

Parameters

user $user
array $error

Array containing error strings Key values can either be a string with a language key or an array that will be passed to vsprintf() with the language key in the first array key.

Return Value

array

Array containing the localized error strings

at line 316
null handle_avatar_delete(driver_interface $db, user $user, array $avatar_data, string $table, string $prefix)

Handle deleting avatars

Parameters

driver_interface $db

phpBB dbal

user $user

phpBB user object

array $avatar_data

Cleaned user data containing the user's avatar data

string $table

Database table from which the avatar should be deleted

string $prefix

Prefix of user data columns in database

Return Value

null

at line 363
array prefix_avatar_columns(string $prefix, array $data)

Prefix avatar columns

Parameters

string $prefix

Column prefix

array $data

Column data

Return Value

array

Column data with prefixed column names