PHP Класс Gdn_PluginManager, vanilla

A singleton class used to identify extensions, register them in a central location, and instantiate/call them when necessary.
Наследование: extends Gdn_Pluggable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$trace Whether or not to trace some event information.

Защищенные свойства (Protected)

Свойство Тип Описание
$alternatePluginSearchPaths
$enabledPlugins A simple list of enabled plugins.
$instances An array of the instances of plugins.
$pluginCache Available plugins. Never access this directly, instead use $this->AvailablePlugins();
$pluginFoldersByPath array
$pluginSearchPaths Search paths for plugins and their files.
$pluginsByClass array

Открытые методы

Метод Описание
__construct ( AddonManager $addonManager = null ) Initialize a new instance of the {@link Gdn_PluginManager} class.
addSearchPath ( ) : boolean TODO: Remove this.
availablePluginFolders ( null $SearchPath = null ) : array | mixed
availablePlugins ( ) Get a list of available plugins.
calcOldInfoArray ( Addon $addon ) : array Calculate an old info array from a new {@link Addon}.
callEventHandler ( object $Sender, string $EventClassName, string $EventName, string $EventHandlerType = 'Handler', array $Options = [] ) : mixed Call a single event handler.
callEventHandlers ( object $Sender, string $EventClassName, string $EventName, string $EventHandlerType = 'Handler' ) : boolean Transfer control to the plugins.
callMethodOverride ( object $Sender, string $ClassName, string $MethodName ) : mixed Looks through $this->_MethodOverrideCollection for a matching method signature to override.
callNewMethod ( object $Sender, string $ClassName, string $MethodName ) : mixed Looks through the registered new methods for a matching method signature to call.
checkPlugin ( string $pluginName ) : boolean Check whether a plugin is enabled.
clearPluginCache ( ) The {@link AddonManager} does all this now.
disablePlugin ( string $pluginName ) : boolean Disable a plugin.
enablePlugin ( $pluginName, Gdn_Validation $validation, boolean $setup = true ) : boolean
enabledPluginFolders ( null $SearchPath = null ) : array
enabledPlugins ( ) : array Get a list of all of the enabled plugins.
findPluginFile ( string $path ) : string | false Deprecated.
forceAutoloaderIndex ( ) The {@link AddonManager} does all this now.
getCallback ( string $ClassName, string $MethodName, string $Type = 'Create' ) : callback Get the callback for an event handler.
getEventHandlers ( $Sender, $EventName, string $HandlerType = 'Handler', array $Options = [] ) : array
getPluginInfo ( string $name, string $accessType = self::ACCESS_PLUGINNAME ) : boolean | array Get the information array for a plugin.
getPluginInstance ( string $name, string $accessType = self::ACCESS_CLASSNAME, mixed $sender = null ) : Gdn_IPlugin Gets an instance of a given plugin.
hasMethodOverride ( string $ClassName, string $MethodName ) : boolean Checks to see if there are any plugins that override the method being executed.
hasNewMethod ( string $ClassName, string $MethodName ) : boolean Checks to see if there are any plugins that create the method being executed.
includePlugins ( ) Includes all of the plugin files for enabled plugins.
indexSearchPath ( string $SearchPath, &$PluginInfo, &$ClassInfo, array | null $PathListing = null ) : boolean | string TODO: Remove this method.
isEnabled ( string $Name ) : boolean Returns whether or not a plugin is enabled.
registerCallback ( string $eventName, callable $callback ) Register a a callback to handle an event.
registerHandler ( string $HandlerClassName, string $HandlerMethodName, string $EventClassName = '', string $EventName = '', string $EventHandlerType = '' ) Registers a plugin method name as a handler.
registerNewMethod ( string $NewMethodClassName, string $NewMethodName, string $EventClassName = '', string $EventName = '' ) Registers a plugin new method.
registerOverride ( string $OverrideClassName, string $OverrideMethodName, string $EventClassName = '', string $EventName = '' ) Registers a plugin override method.
registerPlugin ( $ClassName )
registerPlugins ( ) Register all enabled plugins' event handlers and overrides.
registeredPlugins ( ) : array
removeMobileUnfriendlyPlugins ( ) Removes all plugins that are marked as mobile unfriendly.
removeSearchPath ( ) : boolean TODO: Remove this.
scanPluginFile ( $PluginFile, null $VariableName = null ) : null | void
searchPaths ( boolean $OnlyCustom = false ) : array Get the current search paths
splitAuthors ( string $authorsString, string $format = 'html' ) : array | string Split a string containing several authors.
start ( ) Set up the plugin framework.
started ( ) : boolean Is the plugin manager started?
testPlugin ( string $PluginName ) Test to see if a plugin throws fatal errors.
unregisterPlugin ( $PluginClassName ) : boolean

Приватные методы

Метод Описание
enableAddon ( Addon $addon, boolean $setup ) Enable an addon and do all the stuff that's entailed there.
findPluginFileOld ( string $path ) : string | false Find a plugin file using the old plugin manager method.
pluginHook ( string $pluginName, string $forAction, boolean $callback = false ) : void Hooks to the various actions, i.e. enable, disable and load.
removeFromCollectionByPrefix ( $Prefix, &$Collection )
trace ( string $Message, string $Type = TRACE_INFO ) Trace a message when tracing is turned on.

Описание методов

__construct() публичный Метод

Initialize a new instance of the {@link Gdn_PluginManager} class.
public __construct ( AddonManager $addonManager = null )
$addonManager Vanilla\AddonManager The addon manager that manages all of the addons.

addSearchPath() публичный Метод

TODO: Remove this.
public addSearchPath ( ) : boolean
Результат boolean Deprecated.

availablePluginFolders() публичный Метод

public availablePluginFolders ( null $SearchPath = null ) : array | mixed
$SearchPath null
Результат array | mixed

availablePlugins() публичный Метод

Get a list of available plugins.
Устаревший: Use {@link AddonManager::lookupAllByType()}.
public availablePlugins ( )

calcOldInfoArray() публичный статический Метод

This is a backwards compatibility function only and should not be used for new code.
Устаревший:
public static calcOldInfoArray ( Addon $addon ) : array
$addon Vanilla\Addon The addon to calculate.
Результат array Returns an info array.

callEventHandler() публичный Метод

Call a single event handler.
public callEventHandler ( object $Sender, string $EventClassName, string $EventName, string $EventHandlerType = 'Handler', array $Options = [] ) : mixed
$Sender object The object firing the event.
$EventClassName string The name of the class firing the event.
$EventName string The name of the event being fired.
$EventHandlerType string The type of event handler being looked for.
$Options array An array of options to modify the call.
Результат mixed Returns whatever the event handler returns or **false** of there is not event handler.

callEventHandlers() публичный Метод

Looks through $this->_EventHandlerCollection for matching event signatures to handle. If it finds any, it executes them in the order it found them. It instantiates any plugins and adds them as properties to this class (unless they were previously instantiated), and then calls the handler in question.
public callEventHandlers ( object $Sender, string $EventClassName, string $EventName, string $EventHandlerType = 'Handler' ) : boolean
$Sender object The object that fired the event being handled.
$EventClassName string The name of the class that fired the event being handled.
$EventName string The name of the event being fired.
$EventHandlerType string The type of handler being fired (Handler, Before, After).
Результат boolean Returns **true** if an event was executed.

callMethodOverride() публичный Метод

It instantiates any plugins and adds them as properties to this class (unless they were previously instantiated), then calls the method in question.
public callMethodOverride ( object $Sender, string $ClassName, string $MethodName ) : mixed
$Sender object The object being worked on.
$ClassName string The name of the class that called the method being overridden.
$MethodName string The name of the method that is being overridden.
Результат mixed Returns the value of overridden method.

callNewMethod() публичный Метод

It instantiates any plugins and adds them as properties to this class (unless they were previously instantiated), then calls the method in question.
public callNewMethod ( object $Sender, string $ClassName, string $MethodName ) : mixed
$Sender object The object being worked on.
$ClassName string The name of the class that called the method being created.
$MethodName string The name of the method that is being created.
Результат mixed Return value of new method.

checkPlugin() публичный Метод

Check whether a plugin is enabled.
Устаревший: Use {@link AddonManager::isEnabled()} instead.
public checkPlugin ( string $pluginName ) : boolean
$pluginName string The name of the plugin.
Результат boolean Returns **true** if the plugin is enabled or **false** otherwise.

clearPluginCache() публичный Метод

The {@link AddonManager} does all this now.
Устаревший:
public clearPluginCache ( )

disablePlugin() публичный Метод

Disable a plugin.
public disablePlugin ( string $pluginName ) : boolean
$pluginName string The name of the plugin.
Результат boolean

enablePlugin() публичный Метод

public enablePlugin ( $pluginName, Gdn_Validation $validation, boolean $setup = true ) : boolean
$pluginName
$validation Gdn_Validation
$setup boolean
Результат boolean

enabledPluginFolders() публичный Метод

public enabledPluginFolders ( null $SearchPath = null ) : array
$SearchPath null
Результат array

enabledPlugins() публичный Метод

Get a list of all of the enabled plugins.
public enabledPlugins ( ) : array
Результат array

findPluginFile() публичный Метод

Deprecated.
public findPluginFile ( string $path ) : string | false
$path string Deprecated.
Результат string | false Deprecated.

forceAutoloaderIndex() публичный Метод

The {@link AddonManager} does all this now.
Устаревший:

getCallback() публичный Метод

Get the callback for an event handler.
С версии: 2.1
public getCallback ( string $ClassName, string $MethodName, string $Type = 'Create' ) : callback
$ClassName string The name of the class throwing the event.
$MethodName string The name of the event.
$Type string The type of event handler. - Create: A new method creation. - Override: A method override.
Результат callback

getEventHandlers() публичный Метод

public getEventHandlers ( $Sender, $EventName, string $HandlerType = 'Handler', array $Options = [] ) : array
$Sender
$EventName
$HandlerType string
$Options array
Результат array

getPluginInfo() публичный Метод

Get the information array for a plugin.
Устаревший:
public getPluginInfo ( string $name, string $accessType = self::ACCESS_PLUGINNAME ) : boolean | array
$name string The name of the plugin to access.
$accessType string Either **Gdn_PluginManager::ACCESS_CLASSNAME** or Gdn_PluginManager::ACCESS_PLUGINNAME** (default).
Результат boolean | array Returns an info array or **false** if the plugin isn't found.

getPluginInstance() публичный Метод

Gets an instance of a given plugin.
public getPluginInstance ( string $name, string $accessType = self::ACCESS_CLASSNAME, mixed $sender = null ) : Gdn_IPlugin
$name string The key of the plugin.
$accessType string The type of key for the plugin which must be one of the following: - Gdn_PluginManager::ACCESS_PLUGINNAME - Gdn_PluginManager::ACCESS_CLASSNAME
$sender mixed An object to pass to a new plugin instantiation.
Результат Gdn_IPlugin The plugin instance.

hasMethodOverride() публичный Метод

Checks to see if there are any plugins that override the method being executed.
public hasMethodOverride ( string $ClassName, string $MethodName ) : boolean
$ClassName string The name of the class that called the method being overridden.
$MethodName string The name of the method that is being overridden.
Результат boolean Returns **true** if an override exists or **false** otherwise.

hasNewMethod() публичный Метод

Checks to see if there are any plugins that create the method being executed.
public hasNewMethod ( string $ClassName, string $MethodName ) : boolean
$ClassName string The name of the class that called the method being created.
$MethodName string The name of the method that is being created.
Результат boolean Returns **true** if the method exists.

includePlugins() публичный Метод

Files are included in from the roots of each plugin directory if they have the following names. - default.php - *plugin.php
Устаревший:
public includePlugins ( )

indexSearchPath() публичный Метод

TODO: Remove this method.
Устаревший:
public indexSearchPath ( string $SearchPath, &$PluginInfo, &$ClassInfo, array | null $PathListing = null ) : boolean | string
$SearchPath string Deprecated.
$PathListing array | null Deprecated.
Результат boolean | string Deprecated.

isEnabled() публичный Метод

Returns whether or not a plugin is enabled.
Устаревший:
public isEnabled ( string $Name ) : boolean
$Name string The name of the plugin.
Результат boolean Whether or not the plugin is enabled.

registerCallback() публичный Метод

Register a a callback to handle an event.
public registerCallback ( string $eventName, callable $callback )
$eventName string The name of the event to register.
$callback callable The callback to call when the event is fired.

registerHandler() публичный Метод

Registers a plugin method name as a handler.
public registerHandler ( string $HandlerClassName, string $HandlerMethodName, string $EventClassName = '', string $EventName = '', string $EventHandlerType = '' )
$HandlerClassName string The name of the plugin class that will handle the event.
$HandlerMethodName string The name of the plugin method being registered to handle the event.
$EventClassName string The name of the class that will fire the event.
$EventName string The name of the event that will fire.
$EventHandlerType string The type of event handler.

registerNewMethod() публичный Метод

Registers a plugin new method.
public registerNewMethod ( string $NewMethodClassName, string $NewMethodName, string $EventClassName = '', string $EventName = '' )
$NewMethodClassName string The name of the plugin class that will add a new method.
$NewMethodName string The name of the plugin method being added.
$EventClassName string The name of the class that will fire the event.
$EventName string The name of the event that will fire.

registerOverride() публичный Метод

Registers a plugin override method.
public registerOverride ( string $OverrideClassName, string $OverrideMethodName, string $EventClassName = '', string $EventName = '' )
$OverrideClassName string The name of the plugin class that will override the existing method.
$OverrideMethodName string The name of the plugin method being registered to override the existing method.
$EventClassName string The name of the class that will fire the event.
$EventName string The name of the event that will fire.

registerPlugin() публичный Метод

public registerPlugin ( $ClassName )
$ClassName

registerPlugins() публичный Метод

Examines all declared classes, identifying which ones implement Gdn_IPlugin and registers all of their event handlers and method overrides. It recognizes them because Handlers end with _Handler, _Before, and _After and overrides end with "_Override". They are prefixed with the name of the class and method (or event) to be handled or overridden. For example: class MyPlugin implements Gdn_IPlugin { public function MyController_SignIn_After($Sender) { Do something neato } public function Url_AppRoot_Override($WithDomain) { return "MyCustomAppRoot!"; } }
public registerPlugins ( )

registeredPlugins() публичный Метод

public registeredPlugins ( ) : array
Результат array

removeMobileUnfriendlyPlugins() публичный Метод

Removes all plugins that are marked as mobile unfriendly.

removeSearchPath() публичный Метод

TODO: Remove this.
public removeSearchPath ( ) : boolean
Результат boolean Deprecated.

scanPluginFile() публичный Метод

public scanPluginFile ( $PluginFile, null $VariableName = null ) : null | void
$PluginFile
$VariableName null
Результат null | void

searchPaths() публичный Метод

By default, get all the paths as built by the constructor. Includes the two (or one) default plugin paths of PATH_PLUGINS and PATH_LOCAL_PLUGINS, as well as any extra paths defined in the config variable.
public searchPaths ( boolean $OnlyCustom = false ) : array
$OnlyCustom boolean whether or not to exclude the two default paths and return only config paths
Результат array Search paths

splitAuthors() публичный статический Метод

Split a string containing several authors.
Устаревший: The authors array is already properly split in the {@link Addon}.
public static splitAuthors ( string $authorsString, string $format = 'html' ) : array | string
$authorsString string The author string.
$format string What format to return the result in.
Результат array | string Returns the authors as an array or string if HTML is requested.

start() публичный Метод

Set up the plugin framework.
public start ( )

started() публичный Метод

Is the plugin manager started?
public started ( ) : boolean
Результат boolean Returns **true** if the plugin manager is started or **false** otherwise.

testPlugin() публичный Метод

Test to see if a plugin throws fatal errors.
Устаревший:
public testPlugin ( string $PluginName )
$PluginName string The name of the plugin to test.

unregisterPlugin() публичный Метод

public unregisterPlugin ( $PluginClassName ) : boolean
$PluginClassName
Результат boolean

Описание свойств

$alternatePluginSearchPaths защищенное свойство

protected $alternatePluginSearchPaths

$enabledPlugins защищенное свойство

A simple list of enabled plugins.
protected $enabledPlugins

$instances защищенное свойство

An array of the instances of plugins.
protected $instances

$pluginCache защищенное свойство

Available plugins. Never access this directly, instead use $this->AvailablePlugins();
protected $pluginCache

$pluginFoldersByPath защищенное свойство

protected array $pluginFoldersByPath
Результат array

$pluginSearchPaths защищенное свойство

Search paths for plugins and their files.
protected $pluginSearchPaths

$pluginsByClass защищенное свойство

protected array $pluginsByClass
Результат array

$trace публичное свойство

Whether or not to trace some event information.
public $trace