PHP Class Migration, glpi

Mostrar archivo Open project: glpi-project/glpi Class Usage Examples

Protected Properties

Property Type Description
$version

Public Methods

Method Description
__construct ( $ver )
addField ( $table, $field, $type, $options = [] ) Add a new GLPI normalized field
addKey ( $table, $fields, $indexname = '', $type = 'INDEX', $len ) Add index for migration
addNewMessageArea ( $id )
changeField ( $table, $oldfield, $newfield, $type, $options = [] ) Modify field for migration
copyTable ( $oldtable, $newtable ) Copy table for migration
createRule ( array $rule, array $criteria, array $actions ) : integer Register a new rule
displayMessage ( $msg ) Additional message in global message
displayTitle ( $title ) Display a title
displayWarning ( $msg, $red = false ) Display a Warning
dropField ( $table, $field ) Drop field for migration
dropKey ( $table, $indexname ) Drop index for migration
dropTable ( $table ) Drop immediatly a table if it exists
executeMigration ( ) Execute global migration
flushLogDisplayMessage ( ) Flush previous display message in log file
insertInTable ( $table, array $input ) : id Insert an entry inside a table
log ( $message, $warning ) log message for this migration
migrationOneTable ( $table ) Execute migration for only one table
renameTable ( $oldtable, $newtable ) Rename table for migration
setVersion ( $ver )
updateDisplayPrefs ( $toadd = [], $todel = [] ) Update display preferences

Private Methods

Method Description
fieldFormat ( $type, $default_value, $nodefault = false ) Define field's format

Method Details

__construct() public method

public __construct ( $ver )
$ver number of new version of GLPI

addField() public method

Add a new GLPI normalized field
public addField ( $table, $field, $type, $options = [] )
$table string
$field string to add
$type string (see fieldFormat)
$options array - update : if not empty = value of $field (must be protected) - condition : if needed - value : default_value new field's default value, if a specific default value needs to be used - nodefault : do not define default value (default false) - comment : comment to be added during field creation - after : where adding the new field

addKey() public method

Add index for migration
public addKey ( $table, $fields, $indexname = '', $type = 'INDEX', $len )
$table string
$fields string or array
$indexname string if empty =$fields (default '')
$type string index or unique (default 'INDEX')
$len integer for field length (default 0)

addNewMessageArea() public method

public addNewMessageArea ( $id )
$id

changeField() public method

Modify field for migration
public changeField ( $table, $oldfield, $newfield, $type, $options = [] )
$table string
$oldfield string old name of the field
$newfield string new name of the field
$type string (see fieldFormat)
$options array - default_value new field's default value, if a specific default value needs to be used - comment comment to be added during field creation - nodefault : do not define default value (default false)

copyTable() public method

Copy table for migration
public copyTable ( $oldtable, $newtable )
$oldtable string The name of the table already inside the database
$newtable string The copy of the old table

createRule() public method

Register a new rule
public createRule ( array $rule, array $criteria, array $actions ) : integer
$rule array Array of fields of glpi_rules
$criteria array Array of Array of fields of glpi_rulecriterias
$actions array Array of Array of fields of glpi_ruleactions
return integer : new rule id

displayMessage() public method

Additional message in global message
public displayMessage ( $msg )
$msg text to display

displayTitle() public method

Display a title
public displayTitle ( $title )
$title string

displayWarning() public method

Display a Warning
public displayWarning ( $msg, $red = false )
$msg string
$red boolean (false by default)

dropField() public method

Drop field for migration
public dropField ( $table, $field )
$table string
$field string field to drop

dropKey() public method

Drop index for migration
public dropKey ( $table, $indexname )
$table string
$indexname string

dropTable() public method

Drop immediatly a table if it exists
public dropTable ( $table )

executeMigration() public method

Execute global migration
public executeMigration ( )

flushLogDisplayMessage() public method

Flush previous display message in log file

insertInTable() public method

Insert an entry inside a table
public insertInTable ( $table, array $input ) : id
$table string The table to alter
$input array array The elements to add inside the table
return id of the last item inserted by mysql

log() public method

log message for this migration
public log ( $message, $warning )
$message
$warning

migrationOneTable() public method

Execute migration for only one table
public migrationOneTable ( $table )
$table string

renameTable() public method

Rename table for migration
public renameTable ( $oldtable, $newtable )
$oldtable string
$newtable string

setVersion() public method

public setVersion ( $ver )
$ver number of new version

updateDisplayPrefs() public method

Update display preferences
public updateDisplayPrefs ( $toadd = [], $todel = [] )
$toadd array items to add : itemtype => array of values
$todel array items to del : itemtype => array of values

Property Details

$version protected_oe property

protected $version