PHP Класс Vanilla\Addon

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( string $subdir = '' ) Addon constructor.
__set_state ( array $array ) : Addon Support {@link var_export()} for caching.
check ( boolean $trigger = false ) : array Check the addon for data issues.
checkVersion ( string $version, string $requirement ) Check a version against a version requirement.
comparePriority ( Addon $a, Addon $b ) : integer Compare two addon's by priority so that they can be sorted.
getClassPath ( string $classname, string $relative = self::PATH_FULL ) : string Get the path of a class within this addon.
getClasses ( ) : array Get the classes.
getIcon ( string $relative = self::PATH_ADDON ) : string Get the path to the icon for this addon.
getInfo ( ) : array Get the info.
getInfoValue ( string $key, mixed $default = null ) : mixed Get a single value from the info array.
getKey ( ) : string Get this addon's key.
getName ( ) : string Get this addon's human-readable name.
getPluginClass ( ) : string Get the name of the plugin class for this addon, if any.
getPriority ( ) : integer Get the priority of this addon.
getRawKey ( ) : string Get this addon's raw case-sensitive key.
getRequirements ( ) : array Get the required addons for this addon.
getSpecial ( string $key, mixed $default = null ) : mixed Get an item from the special array.
getSubdir ( ) : string Get the subdir.
getTranslationPaths ( string $locale = '' ) : array Get translation paths.
getType ( ) : string Get the type of addon.
getVersion ( ) : string Get the version number of the addon.
makeFilterCallback ( array $where ) : Closure Return a function that can be used as a callback to filter arrays of {@link Addon} objects.
path ( string $subpath = '', string $relative = self::PATH_FULL ) : string Make a full path from an addon-relative path.
scan ( string $subdir ) Scan a subdirectory and setup this addon.
test ( boolean $throw = true ) : boolean Do a very basic test of this addon.

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

Метод Описание
canonicalizeLocale ( string $locale ) : string Canonicalize a locale string so different representations of the same locale can be used together.
convertRequire ( array $info, array $keys ) Convert the info array style requirements to the composer-like require format.
glob ( string $pattern ) : array Perform a glob from this addon's subdirectory.
scanClassPaths ( )
scanClasses ( ) : array Scan for all of the classes in this addon.
scanFile ( string $path ) : array Looks what classes and namespaces are defined in a file and returns them.
scanInfo ( ) : array | null Get an addon's meta info.
scanInfoArray ( string $subpath ) : array | null Scan an addon's info array.
scanTranslations ( ) Scan the addon for translation files.
setClasses ( array $classes ) : Addon Set the classes.
setInfo ( array $info ) : Addon Set the info.
setSpecialArray ( array $special ) : Addon Set the special array.
setSubdir ( string $subdir ) : Addon Set the root-relative subdirectory of the addon.
setTranslationPaths ( array $translations ) : Addon Set the translation paths.
splitAuthors ( array $author ) : array[array[string]] Split an author array that may contain multiple authors separated by commas.
splitRequirement ( string $requirement ) : array Split a requirements string into comparisons.
testRequirement ( string $version, array $req ) : boolean Test an individual requirement.

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

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

Addon constructor.
public __construct ( string $subdir = '' )
$subdir string The root-relative subdirectory of the addon.

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

Support {@link var_export()} for caching.
public static __set_state ( array $array ) : Addon
$array array The array to load.
Результат Addon Returns a new addon with the properties from {@link $array}.

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

Check the addon for data issues.
public check ( boolean $trigger = false ) : array
$trigger boolean Whether or not to trigger a notice if there are issues.
Результат array Returns an array of issues with the addon.

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

Check a version against a version requirement.
public static checkVersion ( string $version, string $requirement )
$version string The version to check.
$requirement string The version requirement.

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

Compare two addon's by priority so that they can be sorted.
public static comparePriority ( Addon $a, Addon $b ) : integer
$a Addon The first addon to compare.
$b Addon The second addon to compare.
Результат integer Returns -1, 0, or 1.

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

This is a case insensitive lookup.
public getClassPath ( string $classname, string $relative = self::PATH_FULL ) : string
$classname string The name of the class.
$relative string One of the **Addon::PATH*** constants.
Результат string Returns the path or an empty string of the class isn't found.

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

Get the classes.
public getClasses ( ) : array
Результат array Returns the classes.

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

Get the path to the icon for this addon.
public getIcon ( string $relative = self::PATH_ADDON ) : string
$relative string One of the **Addon::PATH_*** constants.
Результат string Returns the path of the icon relative to {@link $relative} or an empty string if there is no icon.

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

Get the info.
public getInfo ( ) : array
Результат array Returns the info.

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

Get a single value from the info array.
public getInfoValue ( string $key, mixed $default = null ) : mixed
$key string The key in the info array.
$default mixed The default value to return if there is no item.
Результат mixed Returns the info value or {@link $default}.

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

Get this addon's key.
public getKey ( ) : string
Результат string Returns the key as a string.

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

Get this addon's human-readable name.
public getName ( ) : string
Результат string Returns the name of the addon or its key if it has no name.

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

Get the name of the plugin class for this addon, if any.
public getPluginClass ( ) : string
Результат string Returns the name of the class or an empty string if it doesn't have one.

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

An addon's priority determines the order of things like translations, autoloading, and event firing. Addons with higher priorities will generally override addons with lower priority.
public getPriority ( ) : integer
Результат integer Returns the priority.

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

Addon's have a lowercase key, but some places still require the uppercase one.
public getRawKey ( ) : string
Результат string Returns the key as a string.

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

Get the required addons for this addon.
public getRequirements ( ) : array
Результат array Returns an array in the form addonKey => version.

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

Get an item from the special array.
public getSpecial ( string $key, mixed $default = null ) : mixed
$key string The key in the special array.
$default mixed The default if the key isn't set.
Результат mixed Returns the special item or {@link $default}.

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

Get the subdir.
public getSubdir ( ) : string
Результат string Returns the subdir.

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

Get translation paths.
public getTranslationPaths ( string $locale = '' ) : array
$locale string If passed then only the translation paths for this locale will be returned.
Результат array Returns an array of translation paths or an array of locale codes pointing to translation paths.

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

Get the type of addon.
public getType ( ) : string
Результат string Returns one of the **Addon::TYPE_*** constants.

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

This is just a convenience method for grabbing the version number from the info array.
public getVersion ( ) : string
Результат string Returns a version number or an empty string if there isn't one.

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

Return a function that can be used as a callback to filter arrays of {@link Addon} objects.
public static makeFilterCallback ( array $where ) : Closure
$where array A where array that filters the info array.
Результат Closure Returns a new closure.

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

Make a full path from an addon-relative path.
public path ( string $subpath = '', string $relative = self::PATH_FULL ) : string
$subpath string The subpath to base the path on, starting with a "/".
$relative string One of the **Addon::PATH_*** constants.
Результат string Returns a full path.

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

Scan a subdirectory and setup this addon.
public scan ( string $subdir )
$subdir string The root-relative subdirectory to scan.

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

The test includes some of the files on this addon which will throw an exception if there are any major issues.
public test ( boolean $throw = true ) : boolean
$throw boolean Whether or not to throw an exception.
Результат boolean Returns **true** if the addon was successfully tested or **false** otherwise.