class ExtensionManager

Properties

protected Extension>|null $extensions

Methods

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

No description

getExtensions()

No description

array
getInstalledPackageNames()

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

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.

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
syncExtensionOrder()

Re-sort and persist the enabled extension order based on current composer.json dependency declarations. Call this after a composer update so that any new or changed optional-dependencies are reflected without requiring a manual enable/disable cycle.

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

void syncExtensionOrder()

Re-sort and persist the enabled extension order based on current composer.json dependency declarations. Call this after a composer update so that any new or changed optional-dependencies are reflected without requiring a manual enable/disable cycle.

Return Value

void

Exceptions

CircularDependenciesException

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 '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

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