phpBB API Documentation
Class

phpbb\extension\manager

class manager

The extension manager provides means to activate/deactivate extensions.

Methods

__construct(ContainerInterface $container, driver_interface $db, config $config, filesystem_interface $filesystem, string $extension_table, string $phpbb_root_path, string $php_ext = 'php', 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

extension_interface 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

enable_step($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

finder get_finder(bool $use_all_available = false)

Instantiates a \phpbb\finder.

Details

at line 50
public __construct(ContainerInterface $container, driver_interface $db, config $config, filesystem_interface $filesystem, string $extension_table, string $phpbb_root_path, string $php_ext = 'php', 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
filesystem_interface $filesystem
string $extension_table The name of the table holding extensions
string $phpbb_root_path Path to the phpbb includes directory.
string $php_ext php file extension, defaults to php
service $cache A cache instance or null
string $cache_name The name of the cache variable, defaults to _ext

at line 75
public null load_extensions()

Loads all extension information from the database

Return Value

null

at line 117
public 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 131
public 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 153
public 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 173
public enable_step($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

$name

at line 247
public 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 263
public 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 326
public 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 342
public 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 405
public 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 418
public 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 461
public 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 483
public 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 504
public 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 523
public 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 542
public 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 553
public 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 567
public 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 582
public 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 609
public 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 620
public finder get_finder(bool $use_all_available = false)

Instantiates a \phpbb\finder.

Parameters

bool $use_all_available Should we load all extensions, or just enabled ones

Return Value

finder An extension finder instance