Documentation

GpmStub extends GPM
in package

Class GpmStub

Table of Contents

Properties

$data  : array<string|int, mixed>
$cache  : array<string|int, mixed>
$install_paths  : array<string|int, mixed>
$items  : array<string|int, mixed>

Methods

__call()  : mixed
Convert function calls for the existing keys into their values.
__clone()  : mixed
Clone the iterator.
__construct()  : mixed
Creates a new GPM instance with Local and Remote packages available
__get()  : mixed
Magic getter method
__isset()  : bool
Magic method to determine if the attribute is set
__toString()  : string
Convents iterator to a comma separated list.
append()  : $this
Append new elements to the list.
calculateMergedDependenciesOfPackages()  : array<string|int, mixed>
Calculates and merges the dependencies of the passed packages
calculateVersionNumberFromDependencyVersion()  : string|null
Returns the actual version from a dependency version string.
checkNextSignificantReleasesAreCompatible()  : bool
Check if two releases are compatible by next significant release
checkNoOtherPackageNeedsTheseDependenciesInALowerVersion()  : void
checkNoOtherPackageNeedsThisDependencyInALowerVersion()  : bool
Check the package identified by $slug can be updated to the version passed as argument.
checkPackagesCanBeInstalled()  : void
Check the passed packages list can be updated
copyPackage()  : string|null
Copy the local zip package to tmp
countInstalled()  : int
Returns the amount of locally installed packages
countUpdates()  : int
Returns the amount of updates available
downloadPackage()  : string|null
Download the zip package via the URL
filter()  : $this
Filter elements from the list
findPackage()  : Package|false
Searches for a Package in the repository
findPackages()  : array<string|int, mixed>
Searches for a list of Packages in the repository
first()  : mixed
Get the first item
getBlueprints()  : array<string|int, mixed>|false
Find/Parse the blueprint file
getDependencies()  : array<string|int, mixed>
Fetch the dependencies, check the installed packages and return an array with the list of packages with associated an information on what to do: install, update or ignore.
getGrav()  : GravCore|null
Returns Grav version available in the repository
getInstallable()  : array<string|int, mixed>
Returns the Locally installable packages
getInstalled()  : Packages
Return the locally installed packages
getInstalledPackage()  : Package|null
Return the instance of a specific Package
getInstalledPlugin()  : Package|null
Return the instance of a specific Plugin
getInstalledPlugins()  : Iterator
Returns the Locally installed plugins
getInstalledTheme()  : Package|null
Return the instance of a specific Theme
getInstalledThemes()  : Iterator
Returns the Locally installed themes
getInstallPath()  : string
Get the install path for a name and a particular type of package
getLatestVersionOfPackage()  : string|null
Get the latest release of a package from the GPM
getPackageName()  : string|false
Try to guess the package name from the source files
getPackagesThatDependOnPackage()  : array<string|int, mixed>
Return the list of packages that have the passed one as dependency
getPackageType()  : string|false
Try to guess the package type from the source files
getReleaseType()  : string|null
Get the release type of a package (stable / testing)
getRepository()  : Packages|null
Returns the list of Plugins and Themes available in the repository
getRepositoryPlugin()  : Package|null
Returns a Plugin from the repository
getRepositoryPlugins()  : Iterator|null
Returns the list of Plugins available in the repository
getRepositoryTheme()  : Package|null
Returns a Theme from the repository
getRepositoryThemes()  : Iterator|null
Returns the list of Themes available in the repository
getUpdatable()  : array<string|int, mixed>
Returns an array of Plugins and Themes that can be updated.
getUpdatablePlugins()  : array<string|int, mixed>
Returns an array of Plugins that can be updated.
getUpdatableThemes()  : array<string|int, mixed>
Returns an array of Themes that can be updated.
getVersionOfDependencyRequiredByPackage()  : mixed|null
Get the required version of a dependency of a package
indexOf()  : string|int|false
isPluginEnabled()  : bool
Returns the plugin's enabled state
isPluginInstalled()  : bool
Checks if a Plugin is installed
isPluginInstalledAsSymlink()  : bool
isPluginUpdatable()  : bool
Checks if a Plugin is updatable
isStableRelease()  : bool
Returns true if the package latest release is stable
isTestingRelease()  : bool
Returns true if the package latest release is testing
isThemeEnabled()  : bool
Checks if a Theme is enabled
isThemeInstalled()  : bool
Checks if a Theme is installed
isThemeUpdatable()  : bool
Checks if a Theme is Updatable
isUpdatable()  : bool
Check if a Plugin or Theme is updatable
last()  : mixed
Get the last item
nth()  : mixed|bool
Return nth item.
prev()  : mixed
Return previous item.
random()  : $this
Pick one or more random entries.
remove()  : void
Remove item from the list.
reverse()  : $this
Reverse the Iterator
shuffle()  : $this
Shuffle items.
slice()  : $this
Slice the list.
sort()  : $this|array<string|int, mixed>
Sorts elements from the list and returns a copy of the list in the proper order
versionFormatIsEqualOrHigher()  : bool
Check if the passed version information contains equal or higher operator
versionFormatIsNextSignificantRelease()  : bool
Check if the passed version information contains next significant release (tilde) operator

Properties

$data

public array<string|int, mixed> $data

$cache

protected array<string|int, mixed> $cache

Internal cache

$install_paths

protected array<string|int, mixed> $install_paths = ['plugins' => 'user/plugins/%name%', 'themes' => 'user/themes/%name%', 'skeletons' => 'user/']

$items

protected array<string|int, mixed> $items = []

Methods

__call()

Convert function calls for the existing keys into their values.

public __call(string $key, mixed $args) : mixed
Parameters
$key : string
$args : mixed
Attributes
#[ReturnTypeWillChange]

__clone()

Clone the iterator.

public __clone() : mixed
Attributes
#[ReturnTypeWillChange]

__construct()

Creates a new GPM instance with Local and Remote packages available

public __construct([bool $refresh = false ][, callable|null $callback = null ]) : mixed
Parameters
$refresh : bool = false

Applies to Remote Packages only and forces a refetch of data

$callback : callable|null = null

Either a function or callback in array notation

__get()

Magic getter method

public __get(string $offset) : mixed
Parameters
$offset : string

Asset name value

Attributes
#[ReturnTypeWillChange]
Return values
mixed —

Asset value

__isset()

Magic method to determine if the attribute is set

public __isset(string $offset) : bool
Parameters
$offset : string

Asset name value

Attributes
#[ReturnTypeWillChange]
Return values
bool —

True if the value is set

__toString()

Convents iterator to a comma separated list.

public __toString() : string
Attributes
#[ReturnTypeWillChange]
Return values
string

append()

Append new elements to the list.

public append(array<string|int, mixed>|Iterator $items) : $this
Parameters
$items : array<string|int, mixed>|Iterator

Items to be appended. Existing keys will be overridden with the new values.

Return values
$this

calculateMergedDependenciesOfPackages()

Calculates and merges the dependencies of the passed packages

public calculateMergedDependenciesOfPackages(array<string|int, mixed> $packages) : array<string|int, mixed>
Parameters
$packages : array<string|int, mixed>
Return values
array<string|int, mixed>

calculateVersionNumberFromDependencyVersion()

Returns the actual version from a dependency version string.

public calculateVersionNumberFromDependencyVersion(string $version) : string|null

Examples: $versionInformation == '~2.0' => returns '2.0' $versionInformation == '>=2.0.2' => returns '2.0.2' $versionInformation == '2.0.2' => returns '2.0.2' $versionInformation == '*' => returns null $versionInformation == '' => returns null

Parameters
$version : string
Return values
string|null

checkNextSignificantReleasesAreCompatible()

Check if two releases are compatible by next significant release

public checkNextSignificantReleasesAreCompatible(string $version1, string $version2) : bool

~1.2 is equivalent to >=1.2 <2.0.0 ~1.2.3 is equivalent to >=1.2.3 <1.3.0

In short, allows the last digit specified to go up

Parameters
$version1 : string

the version string (e.g. '2.0.0' or '1.0')

$version2 : string

the version string (e.g. '2.0.0' or '1.0')

Return values
bool

checkNoOtherPackageNeedsTheseDependenciesInALowerVersion()

public checkNoOtherPackageNeedsTheseDependenciesInALowerVersion(array<string|int, mixed> $dependencies_slugs) : void
Parameters
$dependencies_slugs : array<string|int, mixed>

checkNoOtherPackageNeedsThisDependencyInALowerVersion()

Check the package identified by $slug can be updated to the version passed as argument.

public checkNoOtherPackageNeedsThisDependencyInALowerVersion(string $slug, string $version_with_operator, array<string|int, mixed> $ignore_packages_list) : bool

Thrown an exception if it cannot be updated because another package installed requires it to be at an older version.

Parameters
$slug : string
$version_with_operator : string
$ignore_packages_list : array<string|int, mixed>
Tags
throws
RuntimeException
Return values
bool

checkPackagesCanBeInstalled()

Check the passed packages list can be updated

public checkPackagesCanBeInstalled(array<string|int, mixed> $packages_names_list) : void
Parameters
$packages_names_list : array<string|int, mixed>
Tags
throws
Exception

copyPackage()

Copy the local zip package to tmp

public static copyPackage(string $package_file, string $tmp) : string|null
Parameters
$package_file : string
$tmp : string
Return values
string|null

countInstalled()

Returns the amount of locally installed packages

public countInstalled() : int
Return values
int —

Amount of installed packages

countUpdates()

Returns the amount of updates available

public countUpdates() : int
Return values
int —

Amount of available updates

downloadPackage()

Download the zip package via the URL

public static downloadPackage(string $package_file, string $tmp) : string|null
Parameters
$package_file : string
$tmp : string
Return values
string|null

filter()

Filter elements from the list

public filter([callable|null $callback = null ]) : $this
Parameters
$callback : callable|null = null

A function the receives ($value, $key) and must return a boolean to indicate filter status

Return values
$this

findPackage()

Searches for a Package in the repository

public findPackage(mixed $search[, mixed $ignore_exception = false ]) : Package|false
Parameters
$search : mixed

Can be either the slug or the name

$ignore_exception : mixed = false

True if should not fire an exception (for use in Twig)

Tags
inheritdoc
Return values
Package|false —

Package if found, FALSE if not

findPackages()

Searches for a list of Packages in the repository

public findPackages([mixed $searches = [] ]) : array<string|int, mixed>
Parameters
$searches : mixed = []

An array of either slugs or names

Tags
inheritdoc
Return values
array<string|int, mixed> —

Array of found Packages Format: ['total' => int, 'not_found' => array, ]

first()

Get the first item

public first() : mixed

getBlueprints()

Find/Parse the blueprint file

public static getBlueprints(string $source) : array<string|int, mixed>|false
Parameters
$source : string
Return values
array<string|int, mixed>|false

getDependencies()

Fetch the dependencies, check the installed packages and return an array with the list of packages with associated an information on what to do: install, update or ignore.

public getDependencies(array<string|int, mixed> $packages) : array<string|int, mixed>

ignore means the package is already installed and can be safely left as-is. install means the package is not installed and must be installed. update means the package is already installed and must be updated as a dependency needs a higher version.

Parameters
$packages : array<string|int, mixed>
Tags
throws
RuntimeException
Return values
array<string|int, mixed>

getGrav()

Returns Grav version available in the repository

public getGrav() : GravCore|null
Return values
GravCore|null

getInstallable()

Returns the Locally installable packages

public getInstallable([array<string|int, mixed> $list_type_installed = ['plugins' => true, 'themes' => true] ]) : array<string|int, mixed>
Parameters
$list_type_installed : array<string|int, mixed> = ['plugins' => true, 'themes' => true]
Return values
array<string|int, mixed> —

The installed packages

getInstalled()

Return the locally installed packages

public getInstalled() : Packages
Return values
Packages

getInstalledPackage()

Return the instance of a specific Package

public getInstalledPackage(string $slug) : Package|null
Parameters
$slug : string

The slug of the Package

Return values
Package|null —

The instance of the Package

getInstalledPlugin()

Return the instance of a specific Plugin

public getInstalledPlugin(string $slug) : Package|null
Parameters
$slug : string

The slug of the Plugin

Return values
Package|null —

The instance of the Plugin

getInstalledPlugins()

Returns the Locally installed plugins

public getInstalledPlugins() : Iterator
Return values
Iterator —

The installed plugins

getInstalledTheme()

Return the instance of a specific Theme

public getInstalledTheme(string $slug) : Package|null
Parameters
$slug : string

The slug of the Theme

Return values
Package|null —

The instance of the Theme

getInstalledThemes()

Returns the Locally installed themes

public getInstalledThemes() : Iterator
Return values
Iterator —

The installed themes

getInstallPath()

Get the install path for a name and a particular type of package

public static getInstallPath(string $type, string $name) : string
Parameters
$type : string
$name : string
Return values
string

getLatestVersionOfPackage()

Get the latest release of a package from the GPM

public getLatestVersionOfPackage(string $package_name) : string|null
Parameters
$package_name : string
Return values
string|null

getPackageName()

Try to guess the package name from the source files

public static getPackageName(string $source) : string|false
Parameters
$source : string
Return values
string|false

getPackagesThatDependOnPackage()

Return the list of packages that have the passed one as dependency

public getPackagesThatDependOnPackage(string $slug) : array<string|int, mixed>
Parameters
$slug : string

The slug name of the package

Return values
array<string|int, mixed>

getPackageType()

Try to guess the package type from the source files

public static getPackageType(string $source) : string|false
Parameters
$source : string
Return values
string|false

getReleaseType()

Get the release type of a package (stable / testing)

public getReleaseType(string $package_name) : string|null
Parameters
$package_name : string
Return values
string|null

getRepository()

Returns the list of Plugins and Themes available in the repository

public getRepository() : Packages|null
Return values
Packages|null —

Available Plugins and Themes Format: ['plugins' => array, 'themes' => array]

getRepositoryPlugin()

Returns a Plugin from the repository

public getRepositoryPlugin(string $slug) : Package|null
Parameters
$slug : string

The slug of the Plugin

Return values
Package|null —

Package if found, NULL if not

getRepositoryPlugins()

Returns the list of Plugins available in the repository

public getRepositoryPlugins() : Iterator|null
Return values
Iterator|null —

The Plugins remotely available

getRepositoryTheme()

Returns a Theme from the repository

public getRepositoryTheme(string $slug) : Package|null
Parameters
$slug : string

The slug of the Theme

Return values
Package|null —

Package if found, NULL if not

getRepositoryThemes()

Returns the list of Themes available in the repository

public getRepositoryThemes() : Iterator|null
Return values
Iterator|null —

The Themes remotely available

getUpdatable()

Returns an array of Plugins and Themes that can be updated.

public getUpdatable([array<string|int, mixed> $list_type_update = ['plugins' => true, 'themes' => true] ]) : array<string|int, mixed>

Plugins and Themes are extended with the available property that relies to the remote version

Parameters
$list_type_update : array<string|int, mixed> = ['plugins' => true, 'themes' => true]

specifies what type of package to update

Return values
array<string|int, mixed> —

Array of updatable Plugins and Themes. Format: ['total' => int, 'plugins' => array, 'themes' => array]

getUpdatablePlugins()

Returns an array of Plugins that can be updated.

public getUpdatablePlugins() : array<string|int, mixed>

The Plugins are extended with the available property that relies to the remote version

Return values
array<string|int, mixed> —

Array of updatable Plugins

getUpdatableThemes()

Returns an array of Themes that can be updated.

public getUpdatableThemes() : array<string|int, mixed>

The Themes are extended with the available property that relies to the remote version

Return values
array<string|int, mixed> —

Array of updatable Themes

getVersionOfDependencyRequiredByPackage()

Get the required version of a dependency of a package

public getVersionOfDependencyRequiredByPackage(string $package_slug, string $dependency_slug) : mixed|null
Parameters
$package_slug : string
$dependency_slug : string
Return values
mixed|null

indexOf()

public indexOf(mixed $needle) : string|int|false
Parameters
$needle : mixed

Searched value.

Return values
string|int|false —

Key if found, otherwise false.

isPluginEnabled()

Returns the plugin's enabled state

public isPluginEnabled(string $slug) : bool
Parameters
$slug : string
Return values
bool —

True if the Plugin is Enabled. False if manually set to enable:false. Null otherwise.

isPluginInstalled()

Checks if a Plugin is installed

public isPluginInstalled(string $slug) : bool
Parameters
$slug : string

The slug of the Plugin

Return values
bool —

True if the Plugin has been installed. False otherwise

public isPluginInstalledAsSymlink(string $slug) : bool
Parameters
$slug : string
Return values
bool

isPluginUpdatable()

Checks if a Plugin is updatable

public isPluginUpdatable(string $plugin) : bool
Parameters
$plugin : string

The slug of the Plugin

Return values
bool —

True if the Plugin is updatable. False otherwise

isStableRelease()

Returns true if the package latest release is stable

public isStableRelease(string $package_name) : bool
Parameters
$package_name : string
Return values
bool

isTestingRelease()

Returns true if the package latest release is testing

public isTestingRelease(string $package_name) : bool
Parameters
$package_name : string
Return values
bool

isThemeEnabled()

Checks if a Theme is enabled

public isThemeEnabled(string $slug) : bool
Parameters
$slug : string

The slug of the Theme

Return values
bool —

True if the Theme has been set to the default theme. False if installed, but not enabled. Null otherwise.

isThemeInstalled()

Checks if a Theme is installed

public isThemeInstalled(string $slug) : bool
Parameters
$slug : string

The slug of the Theme

Return values
bool —

True if the Theme has been installed. False otherwise

isThemeUpdatable()

Checks if a Theme is Updatable

public isThemeUpdatable(string $theme) : bool
Parameters
$theme : string

The slug of the Theme

Return values
bool —

True if the Theme is updatable. False otherwise

isUpdatable()

Check if a Plugin or Theme is updatable

public isUpdatable(string $slug) : bool
Parameters
$slug : string

The slug of the package

Return values
bool —

True if updatable. False otherwise or if not found

last()

Get the last item

public last() : mixed

nth()

Return nth item.

public nth(int $key) : mixed|bool
Parameters
$key : int
Return values
mixed|bool

prev()

Return previous item.

public prev() : mixed

random()

Pick one or more random entries.

public random([int $num = 1 ]) : $this
Parameters
$num : int = 1

Specifies how many entries should be picked.

Return values
$this

remove()

Remove item from the list.

public remove(string $key) : void
Parameters
$key : string

reverse()

Reverse the Iterator

public reverse() : $this
Return values
$this

shuffle()

Shuffle items.

public shuffle() : $this
Return values
$this

slice()

Slice the list.

public slice(int $offset[, int|null $length = null ]) : $this
Parameters
$offset : int
$length : int|null = null
Return values
$this

sort()

Sorts elements from the list and returns a copy of the list in the proper order

public sort([callable|null $callback = null ][, bool $desc = false ]) : $this|array<string|int, mixed>
Parameters
$callback : callable|null = null
$desc : bool = false
Return values
$this|array<string|int, mixed>

versionFormatIsEqualOrHigher()

Check if the passed version information contains equal or higher operator

public versionFormatIsEqualOrHigher(string $version) : bool

Example: returns true for $version: '>=2.0'

Parameters
$version : string
Return values
bool

versionFormatIsNextSignificantRelease()

Check if the passed version information contains next significant release (tilde) operator

public versionFormatIsNextSignificantRelease(string $version) : bool

Example: returns true for $version: '~2.0'

Parameters
$version : string
Return values
bool

        
On this page

Search results