class ExtensionManager

Properties

protected Collection|null $extensions

Methods

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

No description

Collection
getExtensions()

No description

array
getInstalledPackageNames()

Returns a flat list of all installed composer package names (including non-extension packages).

Collection
getExtensionsById(array $ids)

No description

Extension|null
getExtension(string $name)

No description

void
enable(string $name)

No description

void
disable(string $name)

No description

void
uninstall(string $name)

No description

void
publishAssets(Extension $extension)

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

void
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.

int|null
migrate(Extension $extension, string $direction = 'up')

Runs the database migrations for the extension.

void
migrateDown(Extension $extension)

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

getMigrator()

The database migrator.

array
getEnabledExtensions()

No description

void
extend(Container $container)

Call on all enabled extensions to extend the Flarum application.

array
getEnabled()

The id's of the enabled extensions.

void
setEnabledExtensions(array $enabledExtensions)

Persist the currently enabled extensions.

array
sortDependencies(array $extensions)

Apply a topological sort to the extensions to ensure that they are in the correct order.

bool
isEnabled(string $extension)

No description

static array
pluckTitles(array $extensions)

Returns the titles of the extensions passed.

static array
resolveExtensionOrder(array $extensionList)

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

extensionFromJson(array $package, string $path)

No description

array|null
subExtensionConfsFromJson(array $package, string $packagePath)

No description

Details

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

Parameters

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

Collection getExtensions()

Return Value

Collection

array getInstalledPackageNames()

Returns a flat list of all installed composer package names (including non-extension packages).

Useful for checking whether a suggested package is already installed.

Return Value

array

Collection getExtensionsById(array $ids)

Parameters

array $ids

Return Value

Collection

Extension|null getExtension(string $name)

Parameters

string $name

Return Value

Extension|null

void enable(string $name)

Parameters

string $name

Return Value

void

void disable(string $name)

Parameters

string $name

Return Value

void

void uninstall(string $name)

Parameters

string $name

Return Value

void

protected void publishAssets(Extension $extension)

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

Parameters

Extension $extension

Return Value

void

protected void unpublishAssets(Extension $extension)

Delete an extension's assets from public view.

Parameters

Extension $extension

Return Value

void

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

int|null migrate(Extension $extension, string $direction = 'up')

Runs the database migrations for the extension.

Parameters

Extension $extension
string $direction

Return Value

int|null

void migrateDown(Extension $extension)

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

Parameters

Extension $extension

Return Value

void

Migrator getMigrator()

The database migrator.

Return Value

Migrator

array getEnabledExtensions()

Return Value

array

void extend(Container $container)

Call on all enabled extensions to extend the Flarum application.

Parameters

Container $container

Return Value

void

array getEnabled()

The id's of the enabled extensions.

Return Value

array

protected void setEnabledExtensions(array $enabledExtensions)

Persist the currently enabled extensions.

Parameters

array $enabledExtensions

Return Value

void

Exceptions

CircularDependenciesException

array sortDependencies(array $extensions)

Apply a topological sort to the extensions to ensure that they are in the correct order.

Parameters

array $extensions

Return Value

array

Exceptions

CircularDependenciesException

bool isEnabled(string $extension)

Parameters

string $extension

Return Value

bool

static array pluckTitles(array $extensions)

Returns the titles of the extensions passed.

Parameters

array $extensions

Return Value

array

static array resolveExtensionOrder(array $extensionList)

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

Effectively just topological sorting.

Parameters

array $extensionList

Return Value

array

protected Extension extensionFromJson(array $package, string $path)

Parameters

array $package
string $path

Return Value

Extension

protected array|null subExtensionConfsFromJson(array $package, string $packagePath)

Parameters

array $package
string $packagePath

Return Value

array|null