class Installer extends JAdapter

Joomla base installer class

Properties

object $manifestClass The manifest trigger class
Extension $extension Extension Table Entry
string $message The output from the install/uninstall scripts
object $manifest The installation manifest XML object

Methods

__construct( string $basepath = __DIR__, string $classprefix = '\\Joomla\\CMS\\Installer\\Adapter', string $adapterfolder = 'Adapter')

Constructor

getDbo()

Get the database connector object

from JAdapter
getAdapter( string $name, array $options = array())

Fetches an adapter and adds it to the internal storage if an instance is not set while also ensuring its a valid adapter name

boolean
setAdapter( string $name, object $adapter = null, array $options = array())

Set an adapter by name

from JAdapter
void
loadAllAdapters( array $options = array())

Loads all adapters.

static  Installer
getInstance( string $basepath = __DIR__, string $classprefix = '\\Joomla\\CMS\\Installer\\Adapter', string $adapterfolder = 'Adapter')

Returns the global Installer object, only creating it if it doesn't already exist.

boolean
isOverwrite()

Get the allow overwrite switch

boolean
setOverwrite( boolean $state = false)

Set the allow overwrite switch

string
getRedirectUrl()

Get the redirect location

void
setRedirectUrl( string $newurl)

Set the redirect location

boolean
isPackageUninstall()

Get whether this installer is uninstalling extensions which are part of a package

void
setPackageUninstall( boolean $uninstall)

Set whether this installer is uninstalling extensions which are part of a package

boolean
isUpgrade()

Get the upgrade switch

boolean
setUpgrade( boolean $state = false)

Set the upgrade switch

getManifest()

Get the installation manifest object

string
getPath( string $name, string $default = null)

Get an installer path by name

void
setPath( string $name, string $value)

Sets an installer path by name

void
pushStep( array $step)

Pushes a step onto the installer stack for rolling back steps

boolean
abort( string $msg = null, string $type = null)

Installation abort method

boolean
install( string $path = null)

Package installation method

boolean
discover_install( integer $eid = null)

Discovered package installation method

discover()

Extension discover method

boolean
update( string $path = null)

Package update method

boolean
uninstall( string $type, mixed $identifier, integer $cid)

Package uninstallation method

boolean
refreshManifestCache( integer $eid)

Refreshes the manifest cache stored in #__extensions

setupInstall( string $route = 'install', boolean $returnAdapter = false)

Prepare for installation: this method sets the installation directory, finds and checks the installation file and verifies the installation type.

mixed
parseQueries( SimpleXMLElement $element)

Backward compatible method to parse through a queries element of the installation manifest file and take appropriate action.

mixed
parseSQLFiles( object $element)

Method to extract the name of a discreet installation sql file from the installation manifest file.

void
setSchemaVersion( SimpleXMLElement $schema, integer $eid)

Set the schema version for an extension by looking at its latest update

boolean
parseSchemaUpdates( SimpleXMLElement $schema, integer $eid)

Method to process the updates for an item

boolean
parseFiles( SimpleXMLElement $element, integer $cid, array $oldFiles = null, array $oldMD5 = null)

Method to parse through a files element of the installation manifest and take appropriate action.

boolean
parseLanguages( SimpleXMLElement $element, integer $cid)

Method to parse through a languages element of the installation manifest and take appropriate action.

boolean
parseMedia( SimpleXMLElement $element, integer $cid)

Method to parse through a media element of the installation manifest and take appropriate action.

string
getParams()

Method to parse the parameters of an extension, build the JSON string for its default parameters, and return the JSON string.

boolean
copyFiles( array $files, boolean $overwrite = null)

Copyfiles

boolean
removeFiles( object $element, integer $cid)

Method to parse through a files element of the installation manifest and remove the files that were installed

boolean
copyManifest( integer $cid = 1)

Copies the installation manifest file to the extension folder in the given client

boolean
findManifest()

Tries to find the package manifest file

isManifest( string $file)

Is the XML file a valid Joomla installation manifest file.

string
generateManifestCache()

Generates a manifest cache

object
cleanDiscoveredExtension( string $type, string $element, string $folder = '', integer $client)

Cleans up discovered extensions if they're being installed some other way

array
findDeletedFiles( array $old_files, array $new_files)

Compares two "files" entries to find deleted files/folders

array
loadMD5Sum( string $filename)

Loads an MD5SUMS file into an associative array

static  array
parseXMLInstallFile( string $path)

Parse a XML install manifest file.

array
getAdapters( array $options = array(), array $custom = array())

Gets a list of available install adapters.

loadAdapter( string $adapter, array $options = array())

Method to load an adapter instance

Details

__construct( string $basepath = __DIR__, string $classprefix = '\\Joomla\\CMS\\Installer\\Adapter', string $adapterfolder = 'Adapter')

Constructor

Parameters

string $basepath Base Path of the adapters
string $classprefix Class prefix of adapters
string $adapterfolder Name of folder to append to base path

JDatabaseDriver getDbo()

Get the database connector object

Return Value

JDatabaseDriver Database connector object

JAdapterInstance|boolean getAdapter( string $name, array $options = array())

Fetches an adapter and adds it to the internal storage if an instance is not set while also ensuring its a valid adapter name

Parameters

string $name Name of adapter to return
array $options Adapter options

Return Value

JAdapterInstance|boolean Adapter of type 'name' or false

boolean setAdapter( string $name, object $adapter = null, array $options = array())

Set an adapter by name

Parameters

string $name Adapter name
object $adapter &$adapter Adapter object
array $options Adapter options

Return Value

boolean True if successful

void loadAllAdapters( array $options = array())

Loads all adapters.

Parameters

array $options Adapter options

Return Value

void

static Installer getInstance( string $basepath = __DIR__, string $classprefix = '\\Joomla\\CMS\\Installer\\Adapter', string $adapterfolder = 'Adapter')

Returns the global Installer object, only creating it if it doesn't already exist.

Parameters

string $basepath Base Path of the adapters
string $classprefix Class prefix of adapters
string $adapterfolder Name of folder to append to base path

Return Value

Installer An installer object

boolean isOverwrite()

Get the allow overwrite switch

Return Value

boolean Allow overwrite switch

boolean setOverwrite( boolean $state = false)

Set the allow overwrite switch

Parameters

boolean $state Overwrite switch state

Return Value

boolean True it state is set, false if it is not

string getRedirectUrl()

Get the redirect location

Return Value

string Redirect location (or null)

void setRedirectUrl( string $newurl)

Set the redirect location

Parameters

string $newurl New redirect location

Return Value

void

boolean isPackageUninstall()

Get whether this installer is uninstalling extensions which are part of a package

Return Value

boolean

void setPackageUninstall( boolean $uninstall)

Set whether this installer is uninstalling extensions which are part of a package

Parameters

boolean $uninstall True if a package triggered the uninstall, false otherwise

Return Value

void

boolean isUpgrade()

Get the upgrade switch

Return Value

boolean

boolean setUpgrade( boolean $state = false)

Set the upgrade switch

Parameters

boolean $state Upgrade switch state

Return Value

boolean True if upgrade, false otherwise

SimpleXMLElement getManifest()

Get the installation manifest object

Return Value

SimpleXMLElement Manifest object

string getPath( string $name, string $default = null)

Get an installer path by name

Parameters

string $name Path name
string $default Default value

Return Value

string Path

void setPath( string $name, string $value)

Sets an installer path by name

Parameters

string $name Path name
string $value Path

Return Value

void

void pushStep( array $step)

Pushes a step onto the installer stack for rolling back steps

Parameters

array $step Installer step

Return Value

void

boolean abort( string $msg = null, string $type = null)

Installation abort method

Parameters

string $msg Abort message from the installer
string $type Package type if defined

Return Value

boolean True if successful

boolean install( string $path = null)

Package installation method

Parameters

string $path Path to package source folder

Return Value

boolean True if successful

boolean discover_install( integer $eid = null)

Discovered package installation method

Parameters

integer $eid Extension ID

Return Value

boolean True if successful

InstallerExtension[] discover()

Extension discover method

Asks each adapter to find extensions

Return Value

InstallerExtension[]

boolean update( string $path = null)

Package update method

Parameters

string $path Path to package source folder

Return Value

boolean True if successful

boolean uninstall( string $type, mixed $identifier, integer $cid)

Package uninstallation method

Parameters

string $type Package type
mixed $identifier Package identifier for adapter
integer $cid Application ID; deprecated in 1.6

Return Value

boolean True if successful

boolean refreshManifestCache( integer $eid)

Refreshes the manifest cache stored in #__extensions

Parameters

integer $eid Extension ID

Return Value

boolean

boolean|InstallerAdapter setupInstall( string $route = 'install', boolean $returnAdapter = false)

Prepare for installation: this method sets the installation directory, finds and checks the installation file and verifies the installation type.

Parameters

string $route The install route being followed
boolean $returnAdapter Flag to return the instantiated adapter

Return Value

boolean|InstallerAdapter InstallerAdapter object if explicitly requested otherwise boolean

mixed parseQueries( SimpleXMLElement $element)

Backward compatible method to parse through a queries element of the installation manifest file and take appropriate action.

Parameters

SimpleXMLElement $element The XML node to process

Return Value

mixed Number of queries processed or False on error

mixed parseSQLFiles( object $element)

Method to extract the name of a discreet installation sql file from the installation manifest file.

Parameters

object $element The XML node to process

Return Value

mixed Number of queries processed or False on error

void setSchemaVersion( SimpleXMLElement $schema, integer $eid)

Set the schema version for an extension by looking at its latest update

Parameters

SimpleXMLElement $schema Schema Tag
integer $eid Extension ID

Return Value

void

boolean parseSchemaUpdates( SimpleXMLElement $schema, integer $eid)

Method to process the updates for an item

Parameters

SimpleXMLElement $schema The XML node to process
integer $eid Extension Identifier

Return Value

boolean Result of the operations

boolean parseFiles( SimpleXMLElement $element, integer $cid, array $oldFiles = null, array $oldMD5 = null)

Method to parse through a files element of the installation manifest and take appropriate action.

Parameters

SimpleXMLElement $element The XML node to process
integer $cid Application ID of application to install to
array $oldFiles List of old files (SimpleXMLElement's)
array $oldMD5 List of old MD5 sums (indexed by filename with value as MD5)

Return Value

boolean True on success

boolean parseLanguages( SimpleXMLElement $element, integer $cid)

Method to parse through a languages element of the installation manifest and take appropriate action.

Parameters

SimpleXMLElement $element The XML node to process
integer $cid Application ID of application to install to

Return Value

boolean True on success

boolean parseMedia( SimpleXMLElement $element, integer $cid)

Method to parse through a media element of the installation manifest and take appropriate action.

Parameters

SimpleXMLElement $element The XML node to process
integer $cid Application ID of application to install to

Return Value

boolean True on success

string getParams()

Method to parse the parameters of an extension, build the JSON string for its default parameters, and return the JSON string.

Return Value

string JSON string of parameter values

boolean copyFiles( array $files, boolean $overwrite = null)

Copyfiles

Copy files from source directory to the target directory

Parameters

array $files Array with filenames
boolean $overwrite True if existing files can be replaced

Return Value

boolean True on success

boolean removeFiles( object $element, integer $cid)

Method to parse through a files element of the installation manifest and remove the files that were installed

Parameters

object $element The XML node to process
integer $cid Application ID of application to remove from

Return Value

boolean True on success

boolean copyManifest( integer $cid = 1)

Copies the installation manifest file to the extension folder in the given client

Parameters

integer $cid Where to copy the installfile [optional: defaults to 1 (admin)]

Return Value

boolean True on success, False on error

boolean findManifest()

Tries to find the package manifest file

Return Value

boolean True on success, False on error

SimpleXMLElement|null isManifest( string $file)

Is the XML file a valid Joomla installation manifest file.

Parameters

string $file An xmlfile path to check

Return Value

SimpleXMLElement|null A \SimpleXMLElement, or null if the file failed to parse

string generateManifestCache()

Generates a manifest cache

Return Value

string serialised manifest data

object cleanDiscoveredExtension( string $type, string $element, string $folder = '', integer $client)

Cleans up discovered extensions if they're being installed some other way

Parameters

string $type The type of extension (component, etc)
string $element Unique element identifier (e.g. com_content)
string $folder The folder of the extension (plugins; e.g. system)
integer $client The client application (administrator or site)

Return Value

object Result of query

array findDeletedFiles( array $old_files, array $new_files)

Compares two "files" entries to find deleted files/folders

Parameters

array $old_files An array of \SimpleXMLElement objects that are the old files
array $new_files An array of \SimpleXMLElement objects that are the new files

Return Value

array An array with the delete files and folders in findDeletedFiles[files] and findDeletedFiles[folders] respectively

array loadMD5Sum( string $filename)

Loads an MD5SUMS file into an associative array

Parameters

string $filename Filename to load

Return Value

array Associative array with filenames as the index and the MD5 as the value

static array parseXMLInstallFile( string $path)

Parse a XML install manifest file.

XML Root tag should be 'install' except for languages which use meta file.

Parameters

string $path Full path to XML file.

Return Value

array XML metadata.

array getAdapters( array $options = array(), array $custom = array())

Gets a list of available install adapters.

Parameters

array $options An array of options to inject into the adapter
array $custom Array of custom install adapters

Return Value

array An array of available install adapters.

InstallerAdapter loadAdapter( string $adapter, array $options = array())

Method to load an adapter instance

Parameters

string $adapter Adapter name
array $options Adapter options

Return Value

InstallerAdapter

Exceptions

InvalidArgumentException