PHP Class OEMigration

(C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011 (C) OpenEyes Foundation, 2011-2013 This file is part of OpenEyes. OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see .
Author: OpenEyes ([email protected])
Inheritance: extends CDbMigration
Mostra file Open project: openeyes/openeyes Class Usage Examples

Public Methods

Method Description
createArchiveTable ( $table )
execute ( string $sql, array $params = [], string $message = null ) Executes a SQL statement.
exportData ( $migrationName, $tables )
getCsvFiles ( ) : null | array
getInsertId ( $table )
getInsertReferentialObjectValue ( $object_type, $pointer )
getMigrationPath ( )
initialiseData ( $migrations_path, $update_pk = null, $data_directory = null ) Initialise tables with default data Filenames must to be in the format "nn_tablename.csv", where nn is the processing order FIXME: This needs to be refactored to use SQL rather than relying on models.
setMigrationPath ( $path = null )
setTestData ( $val )
setVerbose ( $verbose = true )

Protected Methods

Method Description
consolidate ( array $consolidated_migrations ) : boolean
createElementType ( string $event_type, string $name, array $params = [] ) : integer
createOETable ( string $name, array $columns, boolean $versioned = false ) Create a table with the standard OE columns and options.
deleteOEFromMultikeyTable ( string $tableName, array $fieldsValsArray )
dropOETable ( $name, boolean $versioned = false ) Convenience function to drop OE tables from db - versioned defaults to false to mirroe createOETable.
getIdOfElementTypeByClassName ( $className ) : mixed
insertOEElementType ( array $element_types, integer $event_type_id ) : array
insertOEEventType ( $eventTypeName, $eventTypeClass, $eventTypeGroup ) : mixed
versionExistingTable ( string $base_name ) Create a version table for the specified existing OE table.

Private Methods

Method Description
compare_file_basenames ( $a, $b )
exportTable ( string $migrationName, CDbTableSchema $table ) : integer
migrationEcho ( $msg )

Method Details

consolidate() protected method

protected consolidate ( array $consolidated_migrations ) : boolean
$consolidated_migrations array
return boolean

createArchiveTable() public method

public createArchiveTable ( $table )

createElementType() protected method

protected createElementType ( string $event_type, string $name, array $params = [] ) : integer
$event_type string Class name of event type
$name string Name of event
$params array Supported values and defaults are: class_name, display_order (1), default (false), required (false), parent_name (null)
return integer Element type ID

createOETable() protected method

Create a table with the standard OE columns and options.
protected createOETable ( string $name, array $columns, boolean $versioned = false )
$name string
$columns array
$versioned boolean

deleteOEFromMultikeyTable() protected method

protected deleteOEFromMultikeyTable ( string $tableName, array $fieldsValsArray )
$tableName string
$fieldsValsArray array example of fieldsValsArray $fieldsValsArray should look like array( array('column_name'=>'value', 'column_name'=>'val'), )

dropOETable() protected method

Convenience function to drop OE tables from db - versioned defaults to false to mirroe createOETable.
protected dropOETable ( $name, boolean $versioned = false )
$name
$versioned boolean

execute() public method

This method executes the specified SQL statement using {@link dbConnection}.
public execute ( string $sql, array $params = [], string $message = null )
$sql string the SQL statement to be executed
$params array input parameters (name=>value) for the SQL execution. See {@link CDbCommand::execute} for more details.
$message string optional message to display instead of SQL

exportData() public method

public exportData ( $migrationName, $tables )

getCsvFiles() public method

public getCsvFiles ( ) : null | array
return null | array

getIdOfElementTypeByClassName() protected method

protected getIdOfElementTypeByClassName ( $className ) : mixed
$className - string
return mixed - the value of the id. False is returned if there is no value.

getInsertId() public method

public getInsertId ( $table )

getInsertReferentialObjectValue() public method

public getInsertReferentialObjectValue ( $object_type, $pointer )

getMigrationPath() public method

public getMigrationPath ( )

initialiseData() public method

Initialise tables with default data Filenames must to be in the format "nn_tablename.csv", where nn is the processing order FIXME: This needs to be refactored to use SQL rather than relying on models.
public initialiseData ( $migrations_path, $update_pk = null, $data_directory = null )

insertOEElementType() protected method

protected insertOEElementType ( array $element_types, integer $event_type_id ) : array
$element_types array
$event_type_id integer
return array - list of the element_types ids inserted

insertOEEventType() protected method

protected insertOEEventType ( $eventTypeName, $eventTypeClass, $eventTypeGroup ) : mixed
$eventTypeName - string
$eventTypeClass - string
$eventTypeGroup - string
return mixed - the id value of the event_type. False is returned if there is no value.

setMigrationPath() public method

public setMigrationPath ( $path = null )

setTestData() public method

public setTestData ( $val )

setVerbose() public method

public setVerbose ( $verbose = true )

versionExistingTable() protected method

Create a version table for the specified existing OE table.
protected versionExistingTable ( string $base_name )
$base_name string Base table name