PHP 클래스 Gdn_Plugin, vanilla

A simple framework that all plugins should extend. Aside from the implementation of Gdn_IPlugin, this class provides some convenience methods to make plugin development easier and faster.
부터: 2.0
저자: Tim Gunter ([email protected])
상속: extends Gdn_Pluggable, implements Gdn_IPlugin
파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$Sender object

공개 메소드들

메소드 설명
__construct ( ) Initialize a new instance of the {@link Gdn_Plugin} class.
autoToggle ( object $Sender, mixed $Redirect = null ) Automatically handle the toggle effect.
autoTogglePath ( null $Path = null ) : null | string
controller_index ( $sender )
dispatch ( $Sender, array $RequestArgs = [] ) : mixed
getAddon ( ) : Addon Get the addon that this plugin belongs to.
getPluginFolder ( boolean $absolute = true ) : string Get the plugin's folder.
getPluginIndex ( ) : string Gets the case-sensitive plugin key.
getPluginKey ( string $key, mixed $default = null ) : mixed Get a specific value from the plugin info array.
getPluginName ( ) : string Get the human-readable name of the plugin.
getResource ( string $filePath, boolean $include = false, boolean $absolute = true ) : string Gets the path to a file within the plugin's folder (and optionally include it).
getView ( string $ViewName ) : string Converts view files to Render() paths.
getWebResource ( string $filePath, boolean $withDomain = false ) : string Get a static resource for this addon suitable to be served from the browser.
instance ( ) : Gdn_Plugin Get an instance of the calling class.
isEnabled ( ) : boolean Convenience method for determining 2nd level activation.
render ( string $view ) Passthru render request to sender.
setAddon ( Addon $addon ) : Gdn_Plugin Set the addon that this plugin belongs to.
setup ( ) Implementation of {@link Gdn_IPlugin::Setup()}.
userMetaModel ( ) : UserMetaModel Instance of UserMetaModel.

보호된 메소드들

메소드 설명
getUserMeta ( integer | array $userID, string $key, mixed $default = null, boolean $autoUnfold = false ) : array Retries UserMeta information for a UserID/Key pair.
makeMetaKey ( string $relativeUserKey ) : string This method takes a UserKey (short relative form) and prepends the plugin prefix.
setUserMeta ( $UserID, $Key, $Value = null ) : void Sets UserMeta data to the UserMeta table
trimMetaKey ( $FullyQualifiedUserKey ) : string This method trims the plugin prefix from a fully qualified MetaKey.

메소드 상세

__construct() 공개 메소드

Initialize a new instance of the {@link Gdn_Plugin} class.
public __construct ( )

autoToggle() 공개 메소드

Automatically handle the toggle effect.
사용 중단:
public autoToggle ( object $Sender, mixed $Redirect = null )
$Sender object Reference to the invoking controller
$Redirect mixed

autoTogglePath() 공개 메소드

public autoTogglePath ( null $Path = null ) : null | string
$Path null
리턴 null | string

controller_index() 공개 메소드

public controller_index ( $sender )
$sender

dispatch() 공개 메소드

public dispatch ( $Sender, array $RequestArgs = [] ) : mixed
$Sender
$RequestArgs array
리턴 mixed

getAddon() 공개 메소드

Get the addon that this plugin belongs to.
public getAddon ( ) : Addon
리턴 Vanilla\Addon Returns the addon.

getPluginFolder() 공개 메소드

Get the plugin's folder.
public getPluginFolder ( boolean $absolute = true ) : string
$absolute boolean Whether or not the folder should be absolute.
리턴 string Returns the folder or an empty string if there is no addon associated with this object.

getPluginIndex() 공개 메소드

Gets the case-sensitive plugin key.
public getPluginIndex ( ) : string
리턴 string

getPluginKey() 공개 메소드

Get a specific value from the plugin info array.
public getPluginKey ( string $key, mixed $default = null ) : mixed
$key string Name of the key whose value you wish to retrieve.
$default mixed Optional value to return if the key cannot be found.
리턴 mixed value of the provided key or {@link $default} if it isn't found.

getPluginName() 공개 메소드

Get the human-readable name of the plugin.
public getPluginName ( ) : string
리턴 string Returns the name of the plugin.

getResource() 공개 메소드

Gets the path to a file within the plugin's folder (and optionally include it).
public getResource ( string $filePath, boolean $include = false, boolean $absolute = true ) : string
$filePath string A relative path to a file within the plugin's folder.
$include boolean Whether or not to immediately include() the file if it exists.
$absolute boolean Whether or not to prepend the full document root to the path.
리턴 string path to the file

getUserMeta() 보호된 메소드

This method takes a $UserID or array of $UserIDs, and a $Key. It converts the $Key to fully qualified format and then queries for the associated value(s). $Key can contain SQL wildcards, in which case multiple results can be returned. If $UserID is an array, the return value will be a multi dimensional array with the first axis containing UserIDs and the second containing fully qualified UserMetaKeys, associated with their values. If $UserID is a scalar, the return value will be a single dimensional array of $UserMetaKey => $Value pairs.
protected getUserMeta ( integer | array $userID, string $key, mixed $default = null, boolean $autoUnfold = false ) : array
$userID integer | array The UserID or array of UserIDs.
$key string The relative user meta key.
$default mixed An optional default return value if key is not found.
$autoUnfold boolean Automatically return key item for single key queries.
리턴 array Return the results or $Default.

getView() 공개 메소드

This method takes a simple filename and, assuming it is located inside /views/, converts it into a path that is suitable for $Sender->Render().
사용 중단: This method is not themeable and thus not advisable.
public getView ( string $ViewName ) : string
$ViewName string The name of the view file, including extension.
리턴 string Returns the path to the view file, relative to the document root.

getWebResource() 공개 메소드

Get a static resource for this addon suitable to be served from the browser.
public getWebResource ( string $filePath, boolean $withDomain = false ) : string
$filePath string The plugin-relative path of the resource.
$withDomain boolean Whether or not to include the domain.
리턴 string Returns the URL of the resource.

instance() 공개 정적인 메소드

Get an instance of the calling class.
public static instance ( ) : Gdn_Plugin
리턴 Gdn_Plugin

isEnabled() 공개 메소드

This method checks the secondary "Plugin.PLUGINNAME.Enabled" setting that has becoming the de-facto standard for keeping plugins enabled but de-activated.
public isEnabled ( ) : boolean
리턴 boolean Status of plugin's 2nd level activation

makeMetaKey() 보호된 메소드

For example, 'Sig' becomes 'Plugin.Signatures.Sig'
protected makeMetaKey ( string $relativeUserKey ) : string
$relativeUserKey string The relative user meta key.
리턴 string Returns a fully qualified meta key.

render() 공개 메소드

This render method automatically adds the correct ApplicationFolder parameter so that $Sender->Render() will first check the plugin's views/ folder.
public render ( string $view )
$view string The name of the view to render.

setAddon() 공개 메소드

Set the addon that this plugin belongs to.
public setAddon ( Addon $addon ) : Gdn_Plugin
$addon Vanilla\Addon The new addon.
리턴 Gdn_Plugin Returns `$this` for fluent calls.

setUserMeta() 보호된 메소드

This method takes a UserID, Key, and Value, and attempts to set $Key = $Value for $UserID. $Key can be an SQL wildcard, thereby allowing multiple variations of a $Key to be set. $UserID can be an array, thereby allowing multiple users' $Keys to be set to the same $Value. ++ Before any queries are run, $Key is converted to its fully qualified format (Plugin. prepended) ++ to prevent collisions in the meta table when multiple plugins have similar key names. If $Value == NULL, the matching row(s) are deleted instead of updated.
protected setUserMeta ( $UserID, $Key, $Value = null ) : void
$UserID int UserID or array of UserIDs
$Key string relative user key
$Value mixed optional value to set, null to delete
리턴 void

setup() 공개 메소드

Implementation of {@link Gdn_IPlugin::Setup()}.
public setup ( )

trimMetaKey() 보호된 메소드

For example, Plugin.Signatures.Sig would become 'Sig'.
protected trimMetaKey ( $FullyQualifiedUserKey ) : string
리턴 string relative meta key

userMetaModel() 공개 메소드

Instance of UserMetaModel.
public userMetaModel ( ) : UserMetaModel
리턴 UserMetaModel

프로퍼티 상세

$Sender 보호되어 있는 프로퍼티

protected object $Sender
리턴 object