Properties

$name

$name : string

Type

string

$human_name

$human_name : string

Type

string

$package

$package : string

Type

string

$path

$path : string

Type

string

$isTheme

$isTheme : boolean

Type

boolean

$isCore

$isCore : boolean

Type

boolean

$hasHelp

$hasHelp : boolean

Type

boolean

$hasSettings

$hasSettings : boolean

Type

boolean

$status

$status : boolean

Type

boolean

$eventListeners

$eventListeners : array

Type

array

$settings

$settings : array

Type

array

$composer

$composer : array

Type

array

$permissions

$permissions : array

Type

array

$_info

$_info : array

Plugin information.

Type

array

$_permissions

$_permissions : null|array

Permissions tree for this plugin.

Type

null|array

$_defaultConfig

$_defaultConfig : array

Default config.

Type

array

$_packageName

$_packageName : string

Full package name. e.g. `vendor/package`

Type

string

$_vendor

$_vendor : string

Package vendor's name.

Type

string

$_name

$_name : string

Package's name, or plugin's name.

Type

string

$_path

$_path : string

Full path to package's root directory.

Type

string

$_version

$_version : string|null

Package's version number.

Type

string|null

$_cache

$_cache : array

Used internally.

Type

array

Methods

name()

name() : string

Returns package's name, that if whatever comes after the `/` symbol.

Returns

string —

If $this represents a QuickAppsCMS's plugin, then its CamelizedName will be returned

permissions()

permissions() : array

Gets plugin's permissions tree.

Output example:

[
    'administrator' => [
        'Plugin/Controller/action',
        'Plugin/Controller/action2',
        ...
    ],
    'role-machine-name' => [
        'Plugin/Controller/anotherAction',
        'Plugin/Controller/anotherAction2',
    ],
    ...
]

Returns

array —

Permissions index by role's machine-name

__get()

__get(string $property) : mixed

Magic getter to access properties that exists on info().

Parameters

string $property

Name of the property to access

Returns

mixed

info()

info(string $key) : mixed

Gets information for this plugin.

When $full is set to true some additional keys will be repent in the resulting array:

  • settings: Plugin's settings info fetched from DB.
  • composer: Composer JSON information, converted to an array.
  • permissions: Permissions tree for this plugin, see PluginPackage::permissions()

Example:

Reading full information:

$plugin->info();

// returns an array as follow:
[
    'name' => 'User,
    'isTheme' => false,
    'isCore' => true,
    'hasHelp' => true,
    'hasSettings' => false,
    'eventListeners' => [ ... ],
    'status' => 1,
    'path' => '/path/to/plugin',
    'settings' => [ ... ], // only when $full = true
    'composer' => [ ... ], // only when $full = true
    'permissions' => [ ... ], // only when $full = true
]

Additionally the first argument, $key, can be used to get an specific value using a dot syntax path:

$plugin->info('isTheme');
$plugin->info('settings.some_key');

If the given path is not found NULL will be returned

Parameters

string $key

Optional path to read from the resulting array

Returns

mixed —

Plugin information as an array if no key is given, or the requested value if a valid $key was provided, or NULL if $key path is not found

composer()

composer(boolean $full) : array

Gets composer json information for this package.

Parameters

boolean $full

Whether to get full composer schema or not. Defaults to false, only defined keys in JSON file will be fetched

Returns

array —

Package's "composer.json" file as an array, an empty array if corrupt or not found

settings()

settings(string $key) : mixed

Gets settings from DB for this plugin. Or reads a single settings key value.

Parameters

string $key

Which setting to read, the entire settings will be returned if no key is provided

Returns

mixed —

Array of settings if $key was not provided, or the requested value for the given $key (null of key does not exists)

version()

version() : string

Gets version number of this package.

Returns

string —

Package's version, for instance 1.2.x-dev

__debugInfo()

__debugInfo() : array

Returns an array that can be used to describe the internal state of this object.

Returns

array

__construct()

__construct(string $package, string $path, string $version)

Constructor.

Parameters

string $package

Package name as string. e.g. vendor-name/package-name

string $path

Full path to package's root directory

string $version

Package version number

vendor()

vendor() : string

Gets package's vendor name, that is whatever before the `/` symbol.

Returns

string —

If $this represents a QuickAppsCMS's plugin, then an empty string will be returned

path()

path() : string

Returns full path to package's root directory.

Returns

string

versionMatch()

versionMatch(string $constraint) : boolean

Check whether this package's version matches the given $constraint.

Other package types might overwrite this method to provide their own matching logic.

Parameters

string $constraint

A string representing a dependency constraint, for instance, >7.0 || 1.2 or ~1.2

Returns

boolean

dependencies()

dependencies() : array

Gets package's dependencies as an array list.

Example:

$this->dependencies();

// may returns: [
//    'some-vendor/user-work' => '1.0',
//    'another-vendor/calendar' => '1.0.*',
//    'quickapps/cms' => '>=1.0',
//    'php' => '>4.3',
//    'cakephp/cakephp' => '3.*',
// ]

Returns

array —

List of packages and versions this package depends on

__toString()

__toString() : string

String representation of this rule.

Returns

string

cache()

cache(null|string $key, mixed $value) : mixed

Reads, writes or search internal class's cache.

Usages:

  • When reading if no cache key is found NULL will be returned. e.g. $null = static::cache('invalid-key');
  • When writing, this method return the value that was written. e.g. $value = static::cache('key', 'value');
  • Set both arguments to NULL to read the whole cache content at the moment. e.g. $allCache = static::cache()
  • Set key to null and value to anything to find the first key holding the given value. e.g. $key = static::cache(null, 'search key for this value'), if no key for the given value is found NULL will be returned.

Examples:

Writing cache:

static::cache('user_name', 'John');
// returns 'John'

static::cache('user_last', 'Locke');
// returns 'Locke'

Reading cache:

static::cache('user_name');
// returns: John

static::cache('unexisting_key');
// returns: null

static::cache();
// Reads the entire cache
// returns: ['user_name' => 'John', 'user_last' => 'Locke']

Searching keys:

static::cache(null, 'Locke');
// returns: user_last

static::cache(null, 'Unexisting Value');
// returns: null

Parameters

null|string $key

Cache key to read or write, set both $key and $value to get the whole cache information

mixed $value

Values to write into the given $key, or null indicates reading from cache

Returns

mixed

dropCache()

dropCache(string|null $key) : void

Drops the entire cache or a specific key.

Usage:

static::dropCache('user_cache'); // removes "user_cache" only
static::dropCache(); // removes every key

Parameters

string|null $key

Cache key to clear, if NULL the entire cache will be erased.

_getKey()

_getKey(string|array $key) : mixed

Gets info value for the given key.

Parameters

string|array $key

The path to read. String using a dot-syntax, or an array result of exploding by . symbol

Returns

mixed