class Extension (View source)

Defines an extension (file) object.

This class does not implement the Serializable interface since problems occurred when using the serialize method.

Properties

protected string $type

The type of the extension (e.g., 'module').

protected string $pathname

The relative pathname of the extension (e.g., 'core/modules/node/node.info.yml').

protected string|null $filename

The filename of the main extension file (e.g., 'node.module').

protected SplFileInfo $splFileInfo

An SplFileInfo instance for the extension's info file.

protected string $root

The app root.

Methods

__construct(string $root, string $type, string $pathname, string $filename = NULL)

Constructs a new Extension object.

string
getType()

Returns the type of the extension.

string
getName()

Returns the internal name of the extension.

string
getPath()

Returns the relative path of the extension.

string
getPathname()

Returns the relative path and filename of the extension's info file.

string
getFilename()

Returns the filename of the extension's info file.

string|null
getExtensionPathname()

Returns the relative path of the main extension file, if any.

string|null
getExtensionFilename()

Returns the name of the main extension file, if any.

bool
load()

Loads the main extension file, if any.

__call($method, array $args)

Re-routes method calls to SplFileInfo.

array
__sleep()

Magic method implementation to serialize the extension object.

__wakeup()

Magic method implementation to unserialize the extension object.

Details

__construct(string $root, string $type, string $pathname, string $filename = NULL)

Constructs a new Extension object.

Parameters

string $root

The app root.

string $type

The type of the extension; e.g., 'module'.

string $pathname

The relative path and filename of the extension's info file; e.g., 'core/modules/node/node.info.yml'.

string $filename

(optional) The filename of the main extension file; e.g., 'node.module'.

string getType()

Returns the type of the extension.

Return Value

string

string getName()

Returns the internal name of the extension.

Return Value

string

string getPath()

Returns the relative path of the extension.

Return Value

string

string getPathname()

Returns the relative path and filename of the extension's info file.

Return Value

string

string getFilename()

Returns the filename of the extension's info file.

Return Value

string

string|null getExtensionPathname()

Returns the relative path of the main extension file, if any.

Return Value

string|null

string|null getExtensionFilename()

Returns the name of the main extension file, if any.

Return Value

string|null

bool load()

Loads the main extension file, if any.

Return Value

bool

TRUE if this extension has a main extension file, FALSE otherwise.

__call($method, array $args)

Re-routes method calls to SplFileInfo.

Offers all SplFileInfo methods to consumers; e.g., $extension->getMTime().

Parameters

$method
array $args

array __sleep()

Magic method implementation to serialize the extension object.

Return Value

array

The names of all variables that should be serialized.

__wakeup()

Magic method implementation to unserialize the extension object.