PHP Класс Migration, glpi

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$version

Открытые методы

Метод Описание
__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

Приватные методы

Метод Описание
fieldFormat ( $type, $default_value, $nodefault = false ) Define field's format

Описание методов

__construct() публичный Метод

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

addField() публичный Метод

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() публичный Метод

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 addNewMessageArea ( $id )
$id

changeField() публичный Метод

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() публичный Метод

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() публичный Метод

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
Результат integer : new rule id

displayMessage() публичный Метод

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

displayTitle() публичный Метод

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

displayWarning() публичный Метод

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

dropField() публичный Метод

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

dropKey() публичный Метод

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

dropTable() публичный Метод

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

executeMigration() публичный Метод

Execute global migration
public executeMigration ( )

flushLogDisplayMessage() публичный Метод

Flush previous display message in log file

insertInTable() публичный Метод

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
Результат id of the last item inserted by mysql

log() публичный Метод

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

migrationOneTable() публичный Метод

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

renameTable() публичный Метод

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

setVersion() публичный Метод

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

updateDisplayPrefs() публичный Метод

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

Описание свойств

$version защищенное свойство

protected $version