PHP Class FOF30\Utils\InstallScript

ファイルを表示 Open project: akeeba/fof Class Usage Examples

Protected Properties

Property Type Description
$cliScriptFiles array A list of scripts to be copied to the "cli" directory of the site
$cliSourcePath string The path inside your package where cli scripts are stored
$componentName string The component's name
$componentTitle string The title of the component (printed on installation and uninstallation messages)
$isPaid boolean Is this the paid version of the extension? This only determines which files / extensions will be removed.
$maximumJoomlaVersion string The maximum Joomla! version this extension can be installed on
$minimumJoomlaVersion string The minimum Joomla! version required to install this extension
$minimumPHPVersion string The minimum PHP version required to install this extension
$postInstallationMessages array This array contains the message definitions for the Post-installation Messages component added in Joomla! 3.2 and later versions. Each element is also a hashed array. For the keys used in these message definitions please
$removeFilesAllVersions array Obsolete files and folders to remove from both paid and free releases. This is used when you refactor code and some files inevitably become obsolete and need to be removed.
$removeFilesFree array Obsolete files and folders to remove from the free version only. This is used when you move a feature from the free version of your extension to its paid version. If you don't have such a distinction you can ignore this.
$schemaXmlPath string The path where the schema XML files are stored. Its contents depend on the schemaXmlPathRelative variable above true => schemaXmlPath contains a path relative to the component's back-end directory false => schemaXmlPath contains an absolute filesystem path
$schemaXmlPathRelative boolean Is the schemaXmlPath class variable a relative path? If set to true the schemaXmlPath variable contains a path relative to the component's back-end directory. If set to false the schemaXmlPath variable contains an absolute filesystem path.
$uninstallation_queue array The list of obsolete extra modules and plugins to uninstall on component upgrade / installation.

Public Methods

Method Description
postflight ( string $type, JInstallerAdapterComponent $parent ) Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing or updating your component. This is the last chance you've got to perform any additional installations, clean-up, database updates and similar housekeeping functions.
preflight ( string $type, JInstallerAdapterComponent $parent ) : boolean Joomla! pre-flight event. This runs before Joomla! installs or updates the component. This is our last chance to tell Joomla! if it should abort the installation.
uninstall ( JInstallerAdapterComponent $parent ) Runs on uninstallation

Protected Methods

Method Description
_applyPostInstallationMessages ( ) : void Applies the post-installation messages for Joomla! 3.2 or later
addDependency ( string $package, string $dependency ) Adds a package dependency to #__akeeba_common
addPostInstallationMessage ( array $options ) : void Adds or updates a post-installation message (PIM) definition for Joomla! 3.2 or later. You can use this in your post-installation script using this code:
bugfixCantBuildAdminMenus ( ) Joomla! 1.6+ bugfix for "Can not build admin menus"
bugfixDBFunctionReturnedNoError ( ) Bugfix for "DB function returned no error"
copyCliFiles ( JInstallerAdapterComponent $parent ) Copies the CLI scripts into Joomla!'s cli directory
getDependencies ( string $package ) : array Get the dependencies for a package from the #__akeeba_common table
hasDependency ( string $package, string $dependency ) : boolean Do I have a dependency for a package in #__akeeba_common
removeDependency ( string $package, string $dependency ) Removes a package dependency from #__akeeba_common
removeFilesAndFolders ( array $removeList ) Removes obsolete files and folders
renderPostInstallation ( JInstallerAdapterComponent $parent ) Override this method to display a custom component installation message if you so wish
renderPostUninstallation ( JInstallerAdapterComponent $parent ) Override this method to display a custom component uninstallation message if you so wish
setDependencies ( string $package, array $dependencies ) Sets the dependencies for a package into the #__akeeba_common table
uninstallObsoleteSubextensions ( JInstallerAdapterComponent $parent ) : stdClass Uninstalls obsolete subextensions (modules, plugins) bundled with the main extension
uninstallPostInstallationMessages ( )

Private Methods

Method Description
_createAdminMenus ( JInstallerAdapterComponent $parent ) : boolean
_reallyPublishAdminMenuItems ( JInstallerAdapterComponent $parent ) : boolean Make sure the Component menu items are really published!
_rebuildMenu ( ) Tells Joomla! to rebuild its menu structure to make triple-sure that the Components menu items really do exist in the correct place and can really be rendered.

Method Details

_applyPostInstallationMessages() protected method

Applies the post-installation messages for Joomla! 3.2 or later
protected _applyPostInstallationMessages ( ) : void
return void

addDependency() protected method

Adds a package dependency to #__akeeba_common
protected addDependency ( string $package, string $dependency )
$package string The package
$dependency string The dependency to add

addPostInstallationMessage() protected method

The $options array contains the following mandatory keys: extension_id The numeric ID of the extension this message is for (see the #__extensions table) type One of message, link or action. Their meaning is: message Informative message. The user can dismiss it. link The action button links to a URL. The URL is defined in the action parameter. action A PHP action takes place when the action button is clicked. You need to specify the action_file (RAD path to the PHP file) and action (PHP function name) keys. See below for more information. title_key The JText language key for the title of this PIM Example: COM_FOOBAR_POSTINSTALL_MESSAGEONE_TITLE description_key The JText language key for the main body (description) of this PIM Example: COM_FOOBAR_POSTINSTALL_MESSAGEONE_DESCRIPTION action_key The JText language key for the action button. Ignored and not required when type=message Example: COM_FOOBAR_POSTINSTALL_MESSAGEONE_ACTION language_extension The extension name which holds the language keys used above. For example, com_foobar, mod_something, plg_system_whatever, tpl_mytemplate language_client_id Should we load the front-end (0) or back-end (1) language keys? version_introduced Which was the version of your extension where this message appeared for the first time? Example: 3.2.1 enabled Must be 1 for this message to be enabled. If you omit it, it defaults to 1. condition_file The RAD path to a PHP file containing a PHP function which determines whether this message should be shown to the user. @see Template::parsePath() for RAD path format. Joomla! will include this file before calling the condition_method. Example: admin://components/com_foobar/helpers/postinstall.php condition_method The name of a PHP function which will be used to determine whether to show this message to the user. This must be a simple PHP user function (not a class method, static method etc) which returns true to show the message and false to hide it. This function is defined in the condition_file. Example: com_foobar_postinstall_messageone_condition When type=message no additional keys are required. When type=link the following additional keys are required: action The URL which will open when the user clicks on the PIM's action button Example: index.php?option=com_foobar&view=tools&task=installSampleData Then type=action the following additional keys are required: action_file The RAD path to a PHP file containing a PHP function which performs the action of this PIM.
See also: Template::parsePath() for RAD path format. Joomla! will include this file before calling the function defined in the action key below. Example: admin://components/com_foobar/helpers/postinstall.php action The name of a PHP function which will be used to run the action of this PIM. This must be a simple PHP user function (not a class method, static method etc) which returns no result. Example: com_foobar_postinstall_messageone_action
protected addPostInstallationMessage ( array $options ) : void
$options array See description
return void

bugfixCantBuildAdminMenus() protected method

Joomla! 1.6+ bugfix for "Can not build admin menus"

bugfixDBFunctionReturnedNoError() protected method

Bugfix for "DB function returned no error"

copyCliFiles() protected method

Copies the CLI scripts into Joomla!'s cli directory
protected copyCliFiles ( JInstallerAdapterComponent $parent )
$parent JInstallerAdapterComponent

getDependencies() protected method

Get the dependencies for a package from the #__akeeba_common table
protected getDependencies ( string $package ) : array
$package string The package
return array The dependencies

hasDependency() protected method

Do I have a dependency for a package in #__akeeba_common
protected hasDependency ( string $package, string $dependency ) : boolean
$package string The package
$dependency string The dependency to check for
return boolean

postflight() public method

Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing or updating your component. This is the last chance you've got to perform any additional installations, clean-up, database updates and similar housekeeping functions.
public postflight ( string $type, JInstallerAdapterComponent $parent )
$type string install, update or discover_update
$parent JInstallerAdapterComponent Parent object

preflight() public method

Joomla! pre-flight event. This runs before Joomla! installs or updates the component. This is our last chance to tell Joomla! if it should abort the installation.
public preflight ( string $type, JInstallerAdapterComponent $parent ) : boolean
$type string Installation type (install, update, discover_install)
$parent JInstallerAdapterComponent Parent object
return boolean True to let the installation proceed, false to halt the installation

removeDependency() protected method

Removes a package dependency from #__akeeba_common
protected removeDependency ( string $package, string $dependency )
$package string The package
$dependency string The dependency to remove

removeFilesAndFolders() protected method

Removes obsolete files and folders
protected removeFilesAndFolders ( array $removeList )
$removeList array The files and directories to remove

renderPostInstallation() protected method

Override this method to display a custom component installation message if you so wish
protected renderPostInstallation ( JInstallerAdapterComponent $parent )
$parent JInstallerAdapterComponent Parent class calling us

renderPostUninstallation() protected method

Override this method to display a custom component uninstallation message if you so wish
protected renderPostUninstallation ( JInstallerAdapterComponent $parent )
$parent JInstallerAdapterComponent Parent class calling us

setDependencies() protected method

Sets the dependencies for a package into the #__akeeba_common table
protected setDependencies ( string $package, array $dependencies )
$package string The package
$dependencies array The dependencies list

uninstall() public method

Runs on uninstallation
public uninstall ( JInstallerAdapterComponent $parent )
$parent JInstallerAdapterComponent The parent object

uninstallObsoleteSubextensions() protected method

Uninstalls obsolete subextensions (modules, plugins) bundled with the main extension
protected uninstallObsoleteSubextensions ( JInstallerAdapterComponent $parent ) : stdClass
$parent JInstallerAdapterComponent The parent object
return stdClass The subextension uninstallation status

uninstallPostInstallationMessages() protected method

Property Details

$cliScriptFiles protected_oe property

A list of scripts to be copied to the "cli" directory of the site
protected array $cliScriptFiles
return array

$cliSourcePath protected_oe property

The path inside your package where cli scripts are stored
protected string $cliSourcePath
return string

$componentName protected_oe property

The component's name
protected string $componentName
return string

$componentTitle protected_oe property

The title of the component (printed on installation and uninstallation messages)
protected string $componentTitle
return string

$isPaid protected_oe property

Is this the paid version of the extension? This only determines which files / extensions will be removed.
protected bool $isPaid
return boolean

$maximumJoomlaVersion protected_oe property

The maximum Joomla! version this extension can be installed on
protected string $maximumJoomlaVersion
return string

$minimumJoomlaVersion protected_oe property

The minimum Joomla! version required to install this extension
protected string $minimumJoomlaVersion
return string

$minimumPHPVersion protected_oe property

The minimum PHP version required to install this extension
protected string $minimumPHPVersion
return string

$postInstallationMessages protected_oe property

This array contains the message definitions for the Post-installation Messages component added in Joomla! 3.2 and later versions. Each element is also a hashed array. For the keys used in these message definitions please
See also: InstallScript::addPostInstallationMessage
protected array $postInstallationMessages
return array

$removeFilesAllVersions protected_oe property

Obsolete files and folders to remove from both paid and free releases. This is used when you refactor code and some files inevitably become obsolete and need to be removed.
protected array $removeFilesAllVersions
return array

$removeFilesFree protected_oe property

Obsolete files and folders to remove from the free version only. This is used when you move a feature from the free version of your extension to its paid version. If you don't have such a distinction you can ignore this.
protected array $removeFilesFree
return array

$schemaXmlPath protected_oe property

The path where the schema XML files are stored. Its contents depend on the schemaXmlPathRelative variable above true => schemaXmlPath contains a path relative to the component's back-end directory false => schemaXmlPath contains an absolute filesystem path
protected string $schemaXmlPath
return string

$schemaXmlPathRelative protected_oe property

Is the schemaXmlPath class variable a relative path? If set to true the schemaXmlPath variable contains a path relative to the component's back-end directory. If set to false the schemaXmlPath variable contains an absolute filesystem path.
protected bool $schemaXmlPathRelative
return boolean

$uninstallation_queue protected_oe property

The list of obsolete extra modules and plugins to uninstall on component upgrade / installation.
protected array $uninstallation_queue
return array