jInstallerPlugin
extends jInstallerBase
in package
implements
jIInstallerComponent
a class to install a plugin.
Tags
Interfaces, Classes and Traits
Table of Contents
- $componentName : string
- $config : jIniMultiFilesModifier
- combination between mainconfig.ini.php (master) and entrypoint config (overrider)
- $date : string
- $entryPoint : jInstallerEntryPoint
- the entry point property on which the installer is called
- $name : string
- $targetVersions : array<string|int, mixed>
- the versions for which the installer should be called.
- $version : string
- $contextId : mixed
- $dbProfile : string
- $defaultDbProfile : string
- $installWholeApp : bool
- $newContextId : mixed
- $parameters : array<string|int, mixed>
- parameters for the installer, indicated in the configuration file or dynamically, by a launcher in a command line for instance.
- $path : string
- The path of the module
- $_dbConn : jDbConnection
- $newEntrypoints : array<string|int, mixed>
- list of new entrypoints.
- __construct() : mixed
- createEntryPoint() : mixed
- declarePluginsPath() : mixed
- declare a plugins directory
- getContexts() : mixed
- getNewEntrypoints() : mixed
- getParameter() : mixed
- install() : mixed
- should configure the plugin, install table into the database etc.. If an error occurs during the installation, you are responsible to cancel/revert all things the method did before the error
- postInstall() : mixed
- Redefine this method if you do some additionnal process after the installation of all other modules/plugins (dependents modules or the whole application)
- postUninstall() : mixed
- preInstall() : mixed
- Called before the installation of all other modules and plugins (dependents modules or the whole application).
- preUninstall() : mixed
- Called before the uninstallation of all other modules (dependents modules or the whole application).
- setEntryPoint() : mixed
- is called to indicate that the installer will be called for the given configuration, entry point and db profile.
- setParameters() : mixed
- uninstall() : mixed
- should configure the module, install table into the database etc.
- copyDirectoryContent() : mixed
- copy the whole content of a directory existing in the install/ directory of the component, to the given directory
- copyFile() : mixed
- copy a file from the install/ directory to an other
- dbConnection() : jDbConnection
- dbTool() : jDbTools
- declareDbProfile() : bool
- declare a new db profile. if the content of the section is not given, it will declare an alias to the default profile
- execSQLScript() : mixed
- import a sql script into the current profile.
- expandPath() : mixed
- firstConfExec() : mixed
- firstDbExec() : mixed
- firstExec() : mixed
- getDbType() : string
- insertDaoData() : int
- Insert data into a database, from a json file, using a DAO mapping
- useDbProfile() : mixed
- use the given database profile. check if this is an alias and use the real db profile if this is the case.
Properties
$componentName
public
string
$componentName
name of the component
$config
combination between mainconfig.ini.php (master) and entrypoint config (overrider)
public
jIniMultiFilesModifier
$config
$date
public
string
$date
= ''
the date of the release of the update. format: yyyy-mm-dd hh:ii
Tags
$entryPoint
the entry point property on which the installer is called
public
jInstallerEntryPoint
$entryPoint
$name
public
string
$name
name of the installer
$targetVersions
the versions for which the installer should be called.
public
array<string|int, mixed>
$targetVersions
= array()
Useful for an upgrade which target multiple branches of a project. Put the version for multiple branches. The installer will be called only once, for the needed version. If you don't fill it, the name of the class file should contain the target version (deprecated behavior though)
list of version by asc order
Tags
$version
public
string
$version
= '0'
the version for which the installer is called
$contextId
protected
mixed
$contextId
= array()
$dbProfile
protected
string
$dbProfile
= ''
the jDb profile for the component
$defaultDbProfile
protected
string
$defaultDbProfile
= ''
the default profile name for the component, if it exist. keep it to '' if not
$installWholeApp
protected
bool
$installWholeApp
= alse
true if this is an installation for the whole application. false if this is an installation in an already installed application. Always False for upgraders.
$newContextId
protected
mixed
$newContextId
= array()
$parameters
parameters for the installer, indicated in the configuration file or dynamically, by a launcher in a command line for instance.
protected
array<string|int, mixed>
$parameters
= array()
$path
The path of the module
protected
string
$path
$_dbConn
private
jDbConnection
$_dbConn
=
ull
$newEntrypoints
list of new entrypoints.
private
array<string|int, mixed>
$newEntrypoints
= array()
keys are ep id, value are array with 'file', 'config', 'type' keys
Methods
__construct()
public
__construct(string $componentName, string $name, string $path, string $version[, bool $installWholeApp = false ]) : mixed
Parameters
- $componentName : string
-
name of the component
- $name : string
-
name of the installer
- $path : string
-
the component path
- $version : string
-
version of the component
- $installWholeApp : bool = false
-
true if the installation is during the whole app installation false if it is only few modules and this module
Return values
mixed —createEntryPoint()
public
createEntryPoint(string $entryPointFile, string $configurationFile[, string $targetConfigDirName = '' ][, string $type = 'classic' ]) : mixed
Parameters
- $entryPointFile : string
-
path to the entrypoint file to copy, from the install directory
- $configurationFile : string
-
path to the configuration file of the entrypoint to copy, from the install directory
- $targetConfigDirName : string = ''
-
directory name into var/config where to copy the configuration file. by default, the directory name is the entrypoint name.
- $type : string = 'classic'
-
type of the entrypoint
Return values
mixed —declarePluginsPath()
declare a plugins directory
public
declarePluginsPath(string $path) : mixed
Parameters
- $path : string
-
a path. it could contain aliases like 'app:', 'lib:' or 'module:'
Tags
Return values
mixed —getContexts()
public
getContexts() : mixed
Return values
mixed —getNewEntrypoints()
public
getNewEntrypoints() : mixed
Return values
mixed —getParameter()
public
getParameter(mixed $name) : mixed
Parameters
- $name : mixed
Return values
mixed —install()
should configure the plugin, install table into the database etc.. If an error occurs during the installation, you are responsible to cancel/revert all things the method did before the error
public
install() : mixed
Tags
Return values
mixed —postInstall()
Redefine this method if you do some additionnal process after the installation of all other modules/plugins (dependents modules or the whole application)
public
postInstall() : mixed
Tags
Return values
mixed —postUninstall()
public
postUninstall() : mixed
Tags
Return values
mixed —preInstall()
Called before the installation of all other modules and plugins (dependents modules or the whole application).
public
preInstall() : mixed
Here, you should check if the plugin can be installed or not
Tags
Return values
mixed —preUninstall()
Called before the uninstallation of all other modules (dependents modules or the whole application).
public
preUninstall() : mixed
Here, you should check if the module can be uninstalled or not
Tags
Return values
mixed —setEntryPoint()
is called to indicate that the installer will be called for the given configuration, entry point and db profile.
public
setEntryPoint(jInstallerEntryPoint $ep, jIniMultiFilesModifier $config, string $dbProfile, array<string|int, mixed> $contexts) : mixed
Parameters
- $ep : jInstallerEntryPoint
-
the entry point
- $config : jIniMultiFilesModifier
-
the configuration of the entry point
- $dbProfile : string
-
the name of the current jdb profile. It will be replaced by $defaultDbProfile if it exists
- $contexts : array<string|int, mixed>
-
list of contexts already executed
Return values
mixed —setParameters()
public
setParameters(mixed $parameters) : mixed
Parameters
- $parameters : mixed
Return values
mixed —uninstall()
should configure the module, install table into the database etc.
public
uninstall() : mixed
.
Tags
Return values
mixed —copyDirectoryContent()
copy the whole content of a directory existing in the install/ directory of the component, to the given directory
protected
final copyDirectoryContent(string $relativeSourcePath, string $targetPath[, mixed $overwrite = false ]) : mixed
Parameters
- $relativeSourcePath : string
-
relative path to the install/ directory of the component
- $targetPath : string
-
the full path where to copy the content
- $overwrite : mixed = false
Return values
mixed —copyFile()
copy a file from the install/ directory to an other
protected
final copyFile(string $relativeSourcePath, string $targetPath[, mixed $overwrite = false ]) : mixed
Parameters
- $relativeSourcePath : string
-
relative path to the install/ directory of the file to copy
- $targetPath : string
-
the full path where to copy the file
- $overwrite : mixed = false
Return values
mixed —dbConnection()
protected
dbConnection() : jDbConnection
Return values
jDbConnection —the connection to the database used for the module
dbTool()
protected
dbTool() : jDbTools
Return values
jDbTools —the tool class of jDb
declareDbProfile()
declare a new db profile. if the content of the section is not given, it will declare an alias to the default profile
protected
declareDbProfile(string $name[, null|string|array<string|int, mixed> $sectionContent = null ][, bool $force = true ]) : bool
Parameters
- $name : string
-
the name of the new section/alias
- $sectionContent : null|string|array<string|int, mixed> = null
-
the content of the new section, or null to create an alias.
- $force : bool = true
-
true:erase the existing profile
Return values
bool —true if the ini file has been changed
execSQLScript()
import a sql script into the current profile.
protected
final execSQLScript(string $name[, string $module = null ][, bool $inTransaction = true ]) : mixed
The name of the script should be store in install/$name.databasetype.sql in the directory of the component. (replace databasetype by mysql, pgsql etc.) You can however provide a script compatible with all databases, but then you should indicate the full name of the script, with a .sql extension.
Parameters
- $name : string
-
the name of the script
- $module : string = null
-
the module from which we should take the sql file. null for the current module
- $inTransaction : bool = true
-
indicate if queries should be executed inside a transaction
Tags
Return values
mixed —expandPath()
protected
expandPath(mixed $path) : mixed
Parameters
- $path : mixed
Return values
mixed —firstConfExec()
protected
firstConfExec([mixed $config = '' ]) : mixed
Parameters
- $config : mixed = ''
Return values
mixed —firstDbExec()
protected
firstDbExec([mixed $profile = '' ]) : mixed
Parameters
- $profile : mixed = ''
Return values
mixed —firstExec()
protected
firstExec(mixed $contextId) : mixed
Parameters
- $contextId : mixed
Return values
mixed —getDbType()
protected
getDbType([string $profile = null ]) : string
Parameters
- $profile : string = null
-
the db profile
Return values
string —the name of the type of database
insertDaoData()
Insert data into a database, from a json file, using a DAO mapping
protected
final insertDaoData(string $relativeSourcePath, int $option[, mixed $module = null ]) : int
Parameters
- $relativeSourcePath : string
-
name of the json file into the install directory
- $option : int
-
one of jDbTools::IBD_* const
- $module : mixed = null
Tags
Return values
int —number of records inserted/updated
useDbProfile()
use the given database profile. check if this is an alias and use the real db profile if this is the case.
protected
useDbProfile(string $dbProfile) : mixed
Parameters
- $dbProfile : string
-
the profile name