Constants

TYPE_ZIP

TYPE_ZIP

Flag that indicates the source package is a ZIP file.

TYPE_URL

TYPE_URL

Flag that indicates the source package is a URL.

TYPE_DIR

TYPE_DIR

Flag that indicates the source package is a directory.

Properties

$tasks

$tasks : array

Contains tasks to load and instantiate.

Type

array

$Plugins

$Plugins : \System\Model\Table\PluginsTable

Type

\System\Model\Table\PluginsTable

$Options

$Options : \System\Model\Table\OptionsTable

Type

\System\Model\Table\OptionsTable

$_addedOptions

$_addedOptions : array

List of option names added during installation. Used to rollback.

Type

array

$_workingDir

$_workingDir : string

Path to package's extracted directory.

Type

string

$_sourceType

$_sourceType : string

The type of the package's source.

Type

string

$_plugin

$_plugin : array

Represents the plugins being installed.

Type

array

$_listeners

$_listeners : array

List of all loaded listeners using "_attachListeners()" method.

Type

array

Methods

startup()

startup() : void

Removes the welcome message.

getOptionParser()

getOptionParser() : \Cake\Console\ConsoleOptionParser

Gets the option parser instance and configures it.

Returns

\Cake\Console\ConsoleOptionParser

main()

main() : boolean

Task main method.

Returns

boolean

trigger()

trigger(array|string $eventName) : \Cake\Event\Event

Triggers the given event name. This method provides a shortcut for:

$this->trigger('EventName', $arg1, $arg2, ..., $argn);

You can provide a subject to use by passing an array as first arguments where the first element is the event name and the second one is the subject, if no subject is given $this will be used by default:

$this->trigger(['GetTime', new MySubject()], $arg_0, $arg_1, ..., $arg_n);

You can also indicate an EventDispatcher instance to use by prefixing the event name with <InstanceName>::, for instance:

$this->trigger('Blog::EventName', $arg1, $arg2, ..., $argn);

This will use the EventDispacher instance named Blog and will trigger the event EventName within that instance.

Parameters

array|string $eventName

The event name to trigger

Returns

\Cake\Event\Event —

The event object that was fired

eventDispatcher()

eventDispatcher(string $name) : \QuickApps\Event\EventDispatcher

Gets an instance of the given Event Dispatcher name.

Usage:

$this->eventDispatcher('myDispatcher')
    ->trigger('MyEventName', $argument)
    ->result;

Parameters

string $name

Name of the dispatcher to get, defaults to 'default'

Returns

\QuickApps\Event\EventDispatcher

triggered()

triggered(string|null $eventName) : integer|array

Retrieves the number of times an event was triggered, or the complete list of events that were triggered.

Parameters

string|null $eventName

The name of the event, if null returns the entire list of event that were fired

Returns

integer|array

_runTransactional()

_runTransactional() : boolean

Runs installation logic inside a safe transactional thread. This prevent DB inconsistencies on install failure.

Returns

boolean —

True on success, false otherwise

_rollbackCopyPackage()

_rollbackCopyPackage() : void

Deletes the directory that was copied to its final destination.

_addOptions()

_addOptions() : boolean

Register on "options" table any declared option is plugin's "composer.json".

Returns

boolean —

True on success, false otherwise

_reset()

_reset() : boolean

Discards the install operation. Restores this class's status to its initial state.

Usage:

return $this->_reset();

Returns

boolean —

False always

_finish()

_finish() : void

After installation is completed.

_copyPackage()

_copyPackage(boolean $clearDestination) : boolean

Copies the extracted package to its final destination.

Parameters

boolean $clearDestination

Set to true to delete the destination directory if already exists. Defaults to false; an error will occur if destination already exists. Useful for upgrade tasks

Returns

boolean —

True on success

_init()

_init() : boolean

Prepares this task and the package to be installed.

Returns

boolean —

True on success

_getFromDirectory()

_getFromDirectory() : boolean

Prepares install from given directory.

Returns

boolean —

True on success

_getFromFile()

_getFromFile() : boolean

Prepares install from ZIP file.

Returns

boolean —

True on success

_getFromUrl()

_getFromUrl() : boolean

Prepares install from remote URL.

Returns

boolean —

True on success

_unzip()

_unzip( $file) : boolean

Extracts the current ZIP package.

Parameters

$file

Returns

boolean —

True on success

_validateContent()

_validateContent() : boolean

Validates the content of working directory.

Returns

boolean —

True on success

_attachListeners()

_attachListeners(string $plugin, string $path)

Loads and registers plugin's namespace and loads its event listeners classes.

This is used to allow plugins being installed to respond to events before they are integrated to the system. Events such as beforeInstall, afterInstall, etc.

Parameters

string $plugin

Name of the plugin for which attach listeners

string $path

Path to plugin's root directory (which contains "src")

Throws

\Cake\Error\FatalErrorException

On illegal usage of this method

_detachListeners()

_detachListeners() : void

Unloads all registered listeners that were attached using the "_attachListeners()" method.