System\Classes\PluginManager


Protected Properties

protected App $app

app instance, since Plugins are an extension of a Service Provider

protected array $plugins

plugins container object used for storing plugin information objects.

protected array $pathMap

pathMap of plugins and their directory paths.

protected bool $registered

registered check if all plugins have had the register() method called.

protected bool $booted

booted check if all plugins have had the boot() method called.

protected string $metaFile

metaFile path to the disabled file.

protected array $disabledPlugins

disabledPlugins collection of disabled plugins

protected array $registrationMethodCache

registrationMethodCache cache of registration method results.


Public Methods

public __construct()

public __construct(): void

__construct this class

public bootAll()

public bootAll($force = false): void

bootAll runs the boot() method on all plugins. Can only be called once.

public bootFromProvider()

public bootFromProvider(): void

bootFromProvider will ensure plugins are not forced on unit tests

public bootPlugin()

public bootPlugin(PluginBase $plugin, $pluginId = null): void 

bootPlugin registers a single plugin object.

public clearDisabledCache()

public clearDisabledCache(): void

public deletePlugin()

public deletePlugin(string $id): void 

deletePlugin completely roll back and delete a plugin from the system.

public disablePlugin()

public disablePlugin(string $id, bool $isUser = false): bool 

disablePlugin disables a single plugin in the system.

public enablePlugin()

public enablePlugin(string $id, bool $isUser = false): bool 

enablePlugin enables a single plugin in the system.

public exists()

public exists(string $id): boolean 

exists checks if a plugin exists and is enabled

public findByIdentifier()

public findByIdentifier($identifier): void

findByIdentifier returns a plugin registration class based on its identifier (Author.Plugin)

public findByNamespace()

public findByNamespace($namespace): void

findByNamespace returns a plugin registration class based on its namespace (Author\Plugin)

public findMissingDependencies()

public findMissingDependencies(): array 

findMissingDependencies scans the system plugins to locate any dependencies that are not currently installed. Returns an array of plugin codes that are needed.

PluginManager::instance()->findMissingDependencies();

public getAllPlugins()

public getAllPlugins(): array|null 

getAllPlugins regardless of enabled state

public getComposerCode()

public getComposerCode($id): void

getComposerCode finds the composer code for a plugin

public getDependencies()

public getDependencies(string $plugin): array 

getDependencies returns the plugin identifiers that are required by the supplied plugin.

public getIdentifier()

public getIdentifier(mixed $namespace): string 

getIdentifier resolves a plugin identifier from a plugin class name or object. Pass in a plugin class name or object, and returns an identifier in format of Vendor.Plugin

public getPluginHints()

public getPluginHints(): array 

getPluginHints returns an array of all registered hints where the key is the hint name and the value is the plugin identifier.

public getPluginNamespace()

public getPluginNamespace($id): string|null 

getPluginNamespace returns the namespace for a plugin

public getPluginNamespaces()

public getPluginNamespaces(): void

getPluginNamespaces returns a flat array of vendor plugin namespaces and their paths

public getPluginPath()

public getPluginPath($id): void

getPluginPath returns the directory path to a plugin

public getPluginPaths()

public getPluginPaths(): void

getPluginPaths returns an array of plugins and their paths.

public getPlugins()

public getPlugins(): void

getPlugins an array with all registered plugins The index is the plugin namespace, the value is the plugin information object.

public getRegistrationMethodValues()

public getRegistrationMethodValues(string $methodName): array 

getRegistrationMethodValues spins over every plugin object and collects the results of a method call.

public getVendorAndPluginNames()

public getVendorAndPluginNames(): void

getVendorAndPluginNames returns a 2 dimensional array of vendors and their plugins.

public hasPlugin()

public hasPlugin($namespace): void

hasPlugin checks to see if a plugin has been registered

public static instance()

public static instance(): static 

instance creates a new instance of this singleton

public isDisabled()

public isDisabled($id): boolean 

isDisabled determines if a plugin is disabled by looking at the meta information or the application configuration.

public listDisabledByConfig()

public listDisabledByConfig(): array 

public loadPlugin()

public loadPlugin($namespace, $path): void

loadPlugin loads a single plugin in to the manager where a namespace is Acme\Blog and the path is somewhere on the disk

public loadPlugins()

public loadPlugins(): array 

loadPlugins finds all available plugins and loads them in to the $plugins array

public normalizeIdentifier()

public normalizeIdentifier(string $identifier): string 

normalizeIdentifier takes a human plugin code (acme.blog) and makes it authentic (Acme.Blog)

public refreshPlugin()

public refreshPlugin(string $id): void 

refreshPlugin tears down a plugin's database tables and rebuilds them.

public registerAll()

public registerAll($force = false): void

registerAll runs the register() method on all plugins and can only be called once

public registerFromProvider()

public registerFromProvider(): void

registerFromProvider will ensure plugins are not forced on unit tests

public registerPlugin()

public registerPlugin(
    PluginBase $plugin,
    string $pluginId = null
): void 

registerPlugin for a single object

public reloadDisabledCache()

public reloadDisabledCache(): void

public reloadPlugins()

public reloadPlugins(): void

unloadPlugins reloads all plugins

public unloadPlugins()

public unloadPlugins(): void

unloadPlugins unloads all plugins: the negative of loadPlugins()

public unregisterAll()

public unregisterAll(): void

Protected Methods

protected callAfterResolving()

protected callAfterResolving($name, $callback): void

callAfterResolving sets up an after resolving listener, or fire immediately if already resolved.

protected loadDependencies()

protected loadDependencies(): void 

loadDependencies cross checks all plugins and their dependencies, if not met plugins are disabled and vice versa.

protected loadDisabled()

protected loadDisabled(): void

loadDisabled loads all disables plugins from the meta file.

protected populateDisabledPluginsFromDb()

protected populateDisabledPluginsFromDb(): void 

populateDisabledPluginsFromDb populates information about disabled plugins from database

protected sortDependencies()

protected sortDependencies(): array 

sortDependencies sorts a collection of plugins, in the order that they should be actioned, according to their given dependencies. Least dependent come first.

protected writeDisabled()

protected writeDisabled(): void

writeDisabled writes the disabled plugins to a meta file.