class ExtensionManager

Properties

protected $config
protected Paths $paths
protected $container
protected $migrator
protected Dispatcher $dispatcher
protected Filesystem $filesystem
protected Collection|null $extensions

Methods

__construct(SettingsRepositoryInterface $config, Paths $paths, Container $container, Migrator $migrator, Dispatcher $dispatcher, Filesystem $filesystem)

No description

Collection
getExtensions()

No description

Extension|null
getExtension(string $name)

Loads an Extension with all information.

enable(string $name)

Enables the extension.

disable(string $name)

Disables an extension.

uninstall(string $name)

Uninstalls an extension.

publishAssets(Extension $extension)

Copy the assets from an extension's assets directory into public view.

unpublishAssets(Extension $extension)

Delete an extension's assets from public view.

string
getAsset(Extension $extension, string $path)

Get the path to an extension's published asset.

Cloud
getAssetsFilesystem()

Get an instance of the assets filesystem.

void
migrate(Extension $extension, string $direction = 'up')

Runs the database migrations for the extension.

array
migrateDown(Extension $extension)

Runs the database migrations to reset the database to its old state.

getMigrator()

The database migrator.

array|Extension[]
getEnabledExtensions()

Get only enabled extensions.

extend(Container $container)

Call on all enabled extensions to extend the Flarum application.

array
getEnabled()

The id's of the enabled extensions.

setEnabledExtensions(array $enabledExtensions)

Persist the currently enabled extensions.

bool
isEnabled($extension)

Whether the extension is enabled.

static string[]
pluckTitles(array $exts)

Returns the titles of the extensions passed.

static array
resolveExtensionOrder(Extension[] $extensionList)

Sort a list of extensions so that they are properly resolved in respect to order.

Details

__construct(SettingsRepositoryInterface $config, Paths $paths, Container $container, Migrator $migrator, Dispatcher $dispatcher, Filesystem $filesystem)

Parameters

SettingsRepositoryInterface $config
Paths $paths
Container $container
Migrator $migrator
Dispatcher $dispatcher
Filesystem $filesystem

Collection getExtensions()

Return Value

Collection

Extension|null getExtension(string $name)

Loads an Extension with all information.

Parameters

string $name

Return Value

Extension|null

enable(string $name)

Enables the extension.

Parameters

string $name

disable(string $name)

Disables an extension.

Parameters

string $name

uninstall(string $name)

Uninstalls an extension.

Parameters

string $name

protected publishAssets(Extension $extension)

Copy the assets from an extension's assets directory into public view.

Parameters

Extension $extension

protected unpublishAssets(Extension $extension)

Delete an extension's assets from public view.

Parameters

Extension $extension

string getAsset(Extension $extension, string $path)

Get the path to an extension's published asset.

Parameters

Extension $extension
string $path

Return Value

string

protected Cloud getAssetsFilesystem()

Get an instance of the assets filesystem.

This is resolved dynamically because Flarum's filesystem configuration might not be booted yet when the ExtensionManager singleton initializes.

Return Value

Cloud

void migrate(Extension $extension, string $direction = 'up')

Runs the database migrations for the extension.

Parameters

Extension $extension
string $direction

Return Value

void

array migrateDown(Extension $extension)

Runs the database migrations to reset the database to its old state.

Parameters

Extension $extension

Return Value

array Notes from the migrator.

Migrator getMigrator()

The database migrator.

Return Value

Migrator

array|Extension[] getEnabledExtensions()

Get only enabled extensions.

Return Value

array|Extension[]

extend(Container $container)

Call on all enabled extensions to extend the Flarum application.

Parameters

Container $container

array getEnabled()

The id's of the enabled extensions.

Return Value

array

protected setEnabledExtensions(array $enabledExtensions)

Persist the currently enabled extensions.

Parameters

array $enabledExtensions

bool isEnabled($extension)

Whether the extension is enabled.

Parameters

$extension

Return Value

bool

static string[] pluckTitles(array $exts)

Returns the titles of the extensions passed.

Parameters

array $exts

Return Value

string[]

static array resolveExtensionOrder(Extension[] $extensionList)

Sort a list of extensions so that they are properly resolved in respect to order.

Effectively just topological sorting.

Parameters

Extension[] $extensionList

Return Value

array with 2 keys: 'valid' points to an ordered array of \Flarum\Extension\Extension 'missingDependencies' points to an associative array of extensions that could not be resolved due to missing dependencies, in the format extension id => array of missing dependency IDs. 'circularDependencies' points to an array of extensions ids of extensions that cannot be processed due to circular dependencies