class manager

The extension manager provides means to activate/deactivate extensions.

Properties

protected ContainerInterface $container
protected $db
protected $config
protected $finder_factory
protected $cache
protected $extensions
protected $extension_table
protected $phpbb_root_path
protected $cache_name

Methods

__construct(ContainerInterface $container, driver_interface $db, config $config, factory $finder_factory, string $extension_table, string $phpbb_root_path, service $cache = null, string $cache_name = '_ext')

Creates a manager and loads information from database

null
load_extensions()

Loads all extension information from the database

string
get_extension_path(string $name, bool $phpbb_relative = false)

Generates the path to an extension

get_extension(string $name)

Instantiates the extension meta class for the extension with the given name

metadata_manager
create_extension_metadata_manager(string $name)

Instantiates the metadata manager for the extension with the given name

update_state(string $name, array $data, string $action = 'update')

Update the database entry for an extension

bool
enable_step(string $name)

Runs a step of the extension enabling process.

null
enable(string $name)

Enables an extension

bool
disable_step(string $name)

Disables an extension

null
disable(string $name)

Disables an extension

bool
purge_step(string $name)

Purge an extension

null
purge(string $name)

Purge an extension

array
all_available()

Retrieves a list of all available extensions on the filesystem

array
all_configured(bool $phpbb_relative = true)

Retrieves all configured extensions.

array
all_enabled(bool $phpbb_relative = true)

Retrieves all enabled extensions.

array
all_disabled(bool $phpbb_relative = true)

Retrieves all disabled extensions.

bool
is_available(string $name)

Check to see if a given extension is available on the filesystem

bool
is_enabled(string $name)

Check to see if a given extension is enabled

bool
is_disabled(string $name)

Check to see if a given extension is disabled

bool
is_configured(string $name)

Check to see if a given extension is configured

array
version_check(metadata_manager $md_manager, bool $force_update = false, bool $force_cache = false, string $stability = null)

Check the version and return the available updates (for an extension).

bool
is_purged(string $name)

Check to see if a given extension is purged

get_finder(bool $use_all_available = false)

Instantiates a \phpbb\finder\finder.

Details

at line 50
__construct(ContainerInterface $container, driver_interface $db, config $config, factory $finder_factory, string $extension_table, string $phpbb_root_path, service $cache = null, string $cache_name = '_ext')

Creates a manager and loads information from database

Parameters

ContainerInterface $container

A container

driver_interface $db

A database connection

config $config

Config object

factory $finder_factory

Finder factory

string $extension_table

The name of the table holding extensions

string $phpbb_root_path

Path to the phpbb includes directory.

service $cache

A cache instance or null

string $cache_name

The name of the cache variable, defaults to _ext

at line 74
null load_extensions()

Loads all extension information from the database

Return Value

null

at line 116
string get_extension_path(string $name, bool $phpbb_relative = false)

Generates the path to an extension

Parameters

string $name

The name of the extension

bool $phpbb_relative

Whether the path should be relative to phpbb root

Return Value

string

Path to an extension

at line 130
extension_interface get_extension(string $name)

Instantiates the extension meta class for the extension with the given name

Parameters

string $name

The extension name

Return Value

extension_interface

Instance of the extension meta class or \phpbb\extension\base if the class does not exist

at line 152
metadata_manager create_extension_metadata_manager(string $name)

Instantiates the metadata manager for the extension with the given name

Parameters

string $name

The extension name

Return Value

metadata_manager

Instance of the metadata manager

at line 169
protected update_state(string $name, array $data, string $action = 'update')

Update the database entry for an extension

Parameters

string $name

Extension name to update

array $data

Data to update in the database

string $action

Action to perform, by default 'update', may be also 'insert' or 'delete'

at line 213
bool enable_step(string $name)

Runs a step of the extension enabling process.

Allows the exentension to enable in a long running script that works in multiple steps across requests. State is kept for the extension in the extensions table.

Parameters

string $name

The extension's name

Return Value

bool

False if enabling is finished, true otherwise

at line 259
null enable(string $name)

Enables an extension

This method completely enables an extension. But it could be long running so never call this in a script that has a max_execution time.

Parameters

string $name

The extension's name

Return Value

null

at line 275
bool disable_step(string $name)

Disables an extension

Calls the disable method on the extension's meta class to allow it to process the event.

Parameters

string $name

The extension's name

Return Value

bool

False if disabling is finished, true otherwise

at line 307
null disable(string $name)

Disables an extension

Disables an extension completely at once. This process could run for a while so never call this in a script that has a max_execution time.

Parameters

string $name

The extension's name

Return Value

null

at line 323
bool purge_step(string $name)

Purge an extension

Disables the extension first if active, and then calls purge on the extension's meta class to delete the extension's database content.

Parameters

string $name

The extension's name

Return Value

bool

False if purging is finished, true otherwise

at line 362
null purge(string $name)

Purge an extension

Purges an extension completely at once. This process could run for a while so never call this in a script that has a max_execution time.

Parameters

string $name

The extension's name

Return Value

null

at line 375
array all_available()

Retrieves a list of all available extensions on the filesystem

Return Value

array

An array with extension names as keys and paths to the extension as values

at line 418
array all_configured(bool $phpbb_relative = true)

Retrieves all configured extensions.

All enabled and disabled extensions are considered configured. A purged extension that is no longer in the database is not configured.

Parameters

bool $phpbb_relative

Whether the path should be relative to phpbb root

Return Value

array

An array with extension names as keys and and the database stored extension information as values

at line 440
array all_enabled(bool $phpbb_relative = true)

Retrieves all enabled extensions.

Parameters

bool $phpbb_relative

Whether the path should be relative to phpbb root

Return Value

array

An array with extension names as keys and and the database stored extension information as values

at line 461
array all_disabled(bool $phpbb_relative = true)

Retrieves all disabled extensions.

Parameters

bool $phpbb_relative

Whether the path should be relative to phpbb root

Return Value

array

An array with extension names as keys and and the database stored extension information as values

at line 480
bool is_available(string $name)

Check to see if a given extension is available on the filesystem

Parameters

string $name

Extension name to check NOTE: Can be user input

Return Value

bool

Depending on whether or not the extension is available

at line 499
bool is_enabled(string $name)

Check to see if a given extension is enabled

Parameters

string $name

Extension name to check

Return Value

bool

Depending on whether or not the extension is enabled

at line 510
bool is_disabled(string $name)

Check to see if a given extension is disabled

Parameters

string $name

Extension name to check

Return Value

bool

Depending on whether or not the extension is disabled

at line 524
bool is_configured(string $name)

Check to see if a given extension is configured

All enabled and disabled extensions are considered configured. A purged extension that is no longer in the database is not configured.

Parameters

string $name

Extension name to check

Return Value

bool

Depending on whether or not the extension is configured

at line 539
array version_check(metadata_manager $md_manager, bool $force_update = false, bool $force_cache = false, string $stability = null)

Check the version and return the available updates (for an extension).

Parameters

metadata_manager $md_manager

The metadata manager for the version to check.

bool $force_update

Ignores cached data. Defaults to false.

bool $force_cache

Force the use of the cache. Override $force_update.

string $stability

Force the stability (null by default).

Return Value

array

Exceptions

runtime_exception

at line 566
bool is_purged(string $name)

Check to see if a given extension is purged

An extension is purged if it is available, not enabled and not disabled.

Parameters

string $name

Extension name to check

Return Value

bool

Depending on whether or not the extension is purged

at line 577
finder get_finder(bool $use_all_available = false)

Instantiates a \phpbb\finder\finder.

Parameters

bool $use_all_available

Should we load all extensions, or just enabled ones

Return Value

finder

An extension finder instance