Installer
Implements DatabaseAwareInterfaceJoomla base installer class
| since |
3.1 |
|---|---|
| package |
Joomla CMS |
Methods
__construct
Constructor
__construct( basepath = __DIR__, classprefix = 'JoomlaCMSInstallerAdapter', adapterfolder = 'Adapter') :
| since |
3.1 |
|---|
Arguments
- basepath
stringBase Path of the adapters- classprefix
stringClass prefix of adapters- adapterfolder
stringName of folder to append to base path
Response
mixed
abort
Installation abort method
abort( msg = null, type = null) :
| since |
3.1 |
|---|
Arguments
- msg
stringAbort message from the installer- type
stringPackage type if defined
Response
boolTrue if successful
cleanDiscoveredExtension
Cleans up discovered extensions if they're being installed some other way
cleanDiscoveredExtension( type, element, folder = '', client) :
| since |
3.1 |
|---|
Arguments
- type
stringThe type of extension (component, etc)- element
stringUnique element identifier (e.g. com_content)- folder
stringThe folder of the extension (plugins; e.g. system)- client
intThe client application (administrator or site)
Response
objectResult of query
copyFiles
Copyfiles
copyFiles(mixed||string|int files, overwrite = null) :
Copy files from source directory to the target directory
| since |
3.1 |
|---|
Arguments
- files
array<string|int, mixed>Array with filenames- overwrite
boolTrue if existing files can be replaced
Response
boolTrue on success
copyManifest
Copies the installation manifest file to the extension folder in the given client
copyManifest( cid = 1) :
| since |
3.1 |
|---|
Arguments
- cid
intWhere to copy the installfile [optional: defaults to 1 (admin)]
Response
boolTrue on success, False on error
def
Sets a default value if not already assigned
def( property, default = null) :
| since |
1.7.0 |
|---|---|
| deprecated |
4.3.0 will be removed in 7.0 Defining dynamic properties should not be used anymore |
Arguments
- property
stringThe name of the property.- default
mixedThe default value.
Response
mixed
discover
Extension discover method
discover() : \Joomla\CMS\Installer\InstallerExtension||string|int
discover_install
Discovered package installation method
discover_install( eid = null) :
| since |
3.1 |
|---|
Arguments
- eid
intExtension ID
Response
boolTrue if successful
findDeletedFiles
Compares two "files" entries to find deleted files/folders
findDeletedFiles(mixed||string|int oldFiles, mixed||string|int newFiles) : mixed||string|int
| since |
3.1 |
|---|
Arguments
- oldFiles
array<string|int, mixed>An array of \SimpleXMLElement objects that are the old files- newFiles
array<string|int, mixed>An array of \SimpleXMLElement objects that are the new files
Response
array<string|int, mixed>An array with the delete files and folders in findDeletedFiles[files] and findDeletedFiles[folders] respectively
findManifest
Tries to find the package manifest file
findManifest() :
| since |
3.1 |
|---|
Response
boolTrue on success, False on error
generateManifestCache
Generates a manifest cache
generateManifestCache() :
| since |
3.1 |
|---|
Response
stringserialised manifest data
get
Returns a property of the object or the default value if the property is not set.
get( property, default = null) :
| since |
1.7.0 |
|---|---|
| see | CMSObject::getProperties() |
| deprecated |
4.3.0 will be removed in 7.0 Create a proper getter function for the property |
Arguments
- property
stringThe name of the property.- default
mixedThe default value.
Response
mixedThe value of the property.
getAdapter
Get an install adapter instance
getAdapter( name, mixed||string|int options = []) : \Joomla\CMS\Installer\InstallerAdapter
| throws |
|
|---|---|
| since |
6.0.0 |
Arguments
- name
stringAdapter name- options
array<string|int, mixed>Adapter options
Response
getAdapters
Gets a list of available install adapters.
getAdapters(mixed||string|int options = [], mixed||string|int custom = []) : string||string|int
| since |
3.4 |
|---|
Arguments
- options
array<string|int, mixed>An array of options to inject into the adapter- custom
array<string|int, mixed>Array of custom install adapters
Response
array<string|int, string>An array of the class names of available install adapters.
getError
Get the most recent error message.
getError( i = null, toString = true) :
| since |
1.7.0 |
|---|---|
| deprecated |
3.1.4 will be removed in 7.0 Will be removed without replacement Catch thrown Exceptions instead of getError |
Arguments
- i
intOption error index.- toString
boolIndicates if Exception objects should return their error message.
Response
stringError message
getErrors
Return all errors, if any.
getErrors() : mixed||string|int
| since |
1.7.0 |
|---|---|
| deprecated |
3.1.4 will be removed in 7.0 Will be removed without replacement Catch thrown Exceptions instead of getErrors |
Response
array<string|int, mixed>Array of error messages.
getInstance
Returns the global Installer object, only creating it if it doesn't already exist.
getInstance( basepath = __DIR__, classprefix = 'JoomlaCMSInstallerAdapter', adapterfolder = 'Adapter') : \Joomla\CMS\Installer\Installer
| since |
3.1 |
|---|
Arguments
- basepath
stringBase Path of the adapters- classprefix
stringClass prefix of adapters- adapterfolder
stringName of folder to append to base path
Response
InstallerAn installer object
getManifest
Get the installation manifest object
getManifest() : \SimpleXMLElement
| since |
3.1 |
|---|
Response
SimpleXMLElementManifest object
getParams
Method to parse the parameters of an extension, build the JSON string for its default parameters, and return the JSON string.
getParams() :
| since |
3.1 |
|---|---|
| note |
This method must always return a JSON compliant string |
Response
stringJSON string of parameter values
getPath
Get an installer path by name
getPath( name, default = null) :
| since |
3.1 |
|---|
Arguments
- name
stringPath name- default
stringDefault value
Response
stringPath
getProperties
Returns an associative array of object properties.
getProperties( public = true) : mixed||string|int
| since |
1.7.0 |
|---|---|
| see | CMSObject::get() |
| deprecated |
4.3.0 will be removed in 7.0 Create a proper getter function for the property |
Arguments
- public
boolIf true, returns only the public properties.
Response
array<string|int, mixed>
getRedirectUrl
Get the redirect location
getRedirectUrl() :
| since |
3.1 |
|---|
Response
stringRedirect location (or null)
install
Package installation method
install( path = null) :
| since |
3.1 |
|---|
Arguments
- path
stringPath to package source folder
Response
boolTrue if successful
isManifest
Is the XML file a valid Joomla installation manifest file.
isManifest( file) : \SimpleXMLElement|null
| since |
3.1 |
|---|
Arguments
- file
stringAn xmlfile path to check
Response
SimpleXMLElement|nullA \SimpleXMLElement, or null if the file failed to parse
isOverwrite
Get the allow overwrite switch
isOverwrite() :
| since |
3.1 |
|---|
Response
boolAllow overwrite switch
isPackageUninstall
Get whether this installer is uninstalling extensions which are part of a package
isPackageUninstall() :
| since |
3.7.0 |
|---|
Response
bool
isUpgrade
Get the upgrade switch
isUpgrade() :
| since |
3.1 |
|---|
Response
bool
loadAdapter
Method to load an adapter instance
loadAdapter( adapter, mixed||string|int options = []) : \Joomla\CMS\Installer\InstallerAdapter
| throws |
|
|---|---|
| since |
3.4 |
| deprecated |
6.0.0 will be removed in 7.0 Use getAdapter() instead |
Arguments
- adapter
stringAdapter name- options
array<string|int, mixed>Adapter options
Response
loadAdapters
Discover all adapters in the adapterfolder path
loadAdapters() :
| since |
6.0.0 |
|---|
Response
void
loadMD5Sum
Loads an MD5SUMS file into an associative array
loadMD5Sum( filename) : mixed||string|int
| since |
3.1 |
|---|
Arguments
- filename
stringFilename to load
Response
array<string|int, mixed>Associative array with filenames as the index and the MD5 as the value
parseFiles
Method to parse through a files element of the installation manifest and take appropriate action.
parseFiles(\SimpleXMLElement element, cid, mixed||string|int oldFiles = null, mixed||string|int oldMD5 = null) :
| since |
3.1 |
|---|
Arguments
- element
SimpleXMLElementThe XML node to process- cid
intApplication ID of application to install to- oldFiles
array<string|int, mixed>List of old files (SimpleXMLElement's)- oldMD5
array<string|int, mixed>List of old MD5 sums (indexed by filename with value as MD5)
Response
boolTrue on success
parseLanguages
Method to parse through a languages element of the installation manifest and take appropriate action.
parseLanguages(\SimpleXMLElement element, cid) :
| since |
3.1 |
|---|
Arguments
- element
SimpleXMLElementThe XML node to process- cid
intApplication ID of application to install to
Response
boolTrue on success
parseMedia
Method to parse through a media element of the installation manifest and take appropriate action.
parseMedia(\SimpleXMLElement element, cid) :
| since |
3.1 |
|---|
Arguments
- element
SimpleXMLElementThe XML node to process- cid
intApplication ID of application to install to
Response
boolTrue on success
parseQueries
Backward compatible method to parse through a queries element of the installation manifest file and take appropriate action.
parseQueries(\SimpleXMLElement element) :
| since |
3.1 |
|---|
Arguments
- element
SimpleXMLElementThe XML node to process
Response
mixedNumber of queries processed or False on error
parseSchemaUpdates
Method to process the updates for an item
parseSchemaUpdates(\SimpleXMLElement schema, eid) : bool|int
| since |
3.1 |
|---|
Arguments
- schema
SimpleXMLElementThe XML node to process- eid
intExtension Identifier
Response
bool|intNumber of SQL updates executed; false on failure.
parseSQLFiles
Method to extract the name of a discreet installation sql file from the installation manifest file.
parseSQLFiles( element) :
| since |
3.1 |
|---|
Arguments
- element
objectThe XML node to process
Response
mixedNumber of queries processed or False on error
parseXMLInstallFile
Parse a XML install manifest file.
parseXMLInstallFile( path) : mixed||string|int
XML Root tag should be 'install' except for languages which use meta file.
| since |
3.0.0 |
|---|
Arguments
- path
stringFull path to XML file.
Response
array<string|int, mixed>XML metadata.
pushStep
Pushes a step onto the installer stack for rolling back steps
pushStep(mixed||string|int step) :
| since |
3.1 |
|---|
Arguments
- step
array<string|int, mixed>Installer step
Response
void
refreshManifestCache
Refreshes the manifest cache stored in #__extensions
refreshManifestCache( eid) :
| since |
3.1 |
|---|
Arguments
- eid
intExtension ID
Response
bool
removeFiles
Method to parse through a files element of the installation manifest and remove the files that were installed
removeFiles( element, cid) :
| since |
3.1 |
|---|
Arguments
- element
objectThe XML node to process- cid
intApplication ID of application to remove from
Response
boolTrue on success
set
Modifies a property of the object, creating it if it does not already exist.
set( property, value = null) :
| since |
1.7.0 |
|---|---|
| deprecated |
4.3.0 will be removed in 7.0 Create a proper setter function for the property |
Arguments
- property
stringThe name of the property.- value
mixedThe value of the property to set.
Response
mixedPrevious value of the property.
setAdapter
Set an adapter by name
setAdapter( name, \Joomla\CMS\Installer\InstallerAdapter|string adapter) :
| since |
6.0.0 |
|---|
Arguments
- name
stringAdapter name- adapter
InstallerAdapter|stringAdapter object or class name
Response
boolTrue if successful
setError
Add an error message.
setError( error) :
| since |
1.7.0 |
|---|---|
| deprecated |
3.1.4 will be removed in 7.0 Will be removed without replacement Throw an Exception instead of using setError |
Arguments
- error
stringError message.
Response
void
setOverwrite
Set the allow overwrite switch
setOverwrite( state = false) :
| since |
3.1 |
|---|
Arguments
- state
boolOverwrite switch state
Response
boolTrue it state is set, false if it is not
setPackageUninstall
Set whether this installer is uninstalling extensions which are part of a package
setPackageUninstall( uninstall) :
| since |
3.7.0 |
|---|
Arguments
- uninstall
boolTrue if a package triggered the uninstall, false otherwise
Response
void
setPath
Sets an installer path by name
setPath( name, value) :
| since |
3.1 |
|---|
Arguments
- name
stringPath name- value
stringPath
Response
void
setProperties
Set the object properties based on a named array/hash.
setProperties( properties) :
| since |
1.7.0 |
|---|---|
| see | CMSObject::set() |
| deprecated |
4.3.0 will be removed in 7.0 Create a proper setter function for the property |
Arguments
- properties
mixedEither an associative array or another object.
Response
bool
setRedirectUrl
Set the redirect location
setRedirectUrl( newurl) :
| since |
3.1 |
|---|
Arguments
- newurl
stringNew redirect location
Response
void
setSchemaVersion
Set the schema version for an extension by looking at its latest update
setSchemaVersion(\SimpleXMLElement schema, eid) :
| since |
3.1 |
|---|
Arguments
- schema
SimpleXMLElementSchema Tag- eid
intExtension ID
Response
void
setUpgrade
Set the upgrade switch
setUpgrade( state = false) :
| since |
3.1 |
|---|
Arguments
- state
boolUpgrade switch state
Response
boolTrue if upgrade, false otherwise
setupInstall
Prepare for installation: this method sets the installation directory, finds and checks the installation file and verifies the installation type.
setupInstall( route = 'install', returnAdapter = false) : bool|\Joomla\CMS\Installer\InstallerAdapter
| since |
3.1 |
|---|
Arguments
- route
stringThe install route being followed- returnAdapter
boolFlag to return the instantiated adapter
Response
bool|InstallerAdapterInstallerAdapter object if explicitly requested otherwise boolean
setUseExceptions
If true then subclasses should throw exceptions rather than use getError and setError.
setUseExceptions( value) :
| since |
5.4.0 |
|---|---|
| deprecated |
7.0 |
Arguments
- value
boolThe value to set for the field.
Response
void
shouldUseExceptions
If true then subclasses should throw exceptions rather than use getError and setError.
shouldUseExceptions() :
| since |
5.4.0 |
|---|---|
| deprecated |
7.0 |
Response
bool
splitSql
Splits a string of multiple queries into an array of individual queries.
splitSql(string|null sql) : mixed||string|int
This is different than DatabaseDriver::splitSql. It supports the special CAN FAIL comment marker which indicates that a SQL statement could fail without raising an error during the installation.
| since |
4.2.0 |
|---|
Arguments
- sql
string|nullInput SQL string with which to split into individual queries.
Response
array<string|int, mixed>
uninstall
Package uninstallation method
uninstall( type, identifier) :
| since |
3.1 |
|---|
Arguments
- type
stringPackage type- identifier
mixedPackage identifier for adapter
Response
boolTrue if successful
update
Package update method
update( path = null) :
| since |
3.1 |
|---|
Arguments
- path
stringPath to package source folder
Response
boolTrue if successful
updateSchemaTable
Update the schema table with the latest version
updateSchemaTable( eid, version, update = false) :
| since |
4.2.0 |
|---|
Arguments
- eid
intExtension ID.- version
stringLatest schema version ID.- update
boolShould I run an update against an existing record or insert a new one?
Response
void
Constants
CAN_FAIL_MARKER
A comment marker to indicate that an update SQL query may fail without triggering an update error.
| Value | '/** CAN FAIL **/' |
|---|---|
| since |
4.2.0 |
CAN_FAIL_MARKER_LENGTH
The length of the CAN_FAIL_MARKER string
| Value | 16 |
|---|---|
| since |
4.2.0 |
Properties
_errors
An array of error messages or Exception objects.
| since |
1.7.0 |
|---|---|
| deprecated |
3.1.4 JError has been deprecated |
Type(s)
array<string|int, mixed>
useExceptions
Use exceptions rather than getError/setError.
| since |
5.4.0 |
|---|---|
| deprecated |
7.0 |
Type(s)
bool
adapters
Array of installer adapters
classprefix
Adapter Class Prefix
| since |
6.0.0 |
|---|
Type(s)
string
adapterfolder
Base Path for the installer adapters
| since |
6.0.0 |
|---|
Type(s)
string
paths
Array of paths needed by the installer
| since |
3.1 |
|---|
Type(s)
array<string|int, mixed>
upgrade
True if package is an upgrade
| since |
3.1 |
|---|
Type(s)
bool
manifestClass
The manifest trigger class
| since |
3.1 |
|---|
Type(s)
object
overwrite
True if existing files can be overwritten
| since |
3.0.0 |
|---|
Type(s)
bool
stepStack
Stack of installation steps
- Used for installation rollback
| since |
3.1 |
|---|
Type(s)
array<string|int, mixed>
message
The output from the install/uninstall scripts
| since |
3.1 |
|---|
Type(s)
string
manifest
The installation manifest XML object
| since |
3.1 |
|---|
Type(s)
object
extension_message
The extension message that appears
| since |
3.1 |
|---|
Type(s)
string
redirect_url
The redirect URL if this extension (can be null if no redirect)
| since |
3.1 |
|---|
Type(s)
string
packageUninstall
Flag if the uninstall process was triggered by uninstalling a package
| since |
3.7.0 |
|---|
Type(s)
bool
extraQuery
Backup extra_query during update_sites rebuild
| since |
3.9.26 |
|---|
Type(s)
string