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
파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$trace Whether or not to trace some event information.

보호된 프로퍼티들

프로퍼티 타입 설명
$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