PHP Class DbPatch_Command_Abstract

Author: Sandy Pleyte
Author: Martijn De Letter
Show file Open project: dbpatch/dbpatch Class Usage Examples

Protected Properties

Property Type Description
$config Zend_Config | Zend_Config_Ini | Zend_Config_Xml
$console DbPatch_Core_Console
$db DbPatch_Core_Db
$options array
$writer DbPatch_Core_Writer

Public Methods

Method Description
execute ( ) : void
getBranch ( ) : string
getConfig ( ) : null | Zend_Config | Zend_Config_Ini | Zend_Config_Xml
getConsole ( ) : DbPatch_Core_Console | null
getDb ( ) : null | Zend_Db_Adapter_Abstract
getOptions ( ) : array
getPatch ( integer $patchNumber, string $branch ) : boolean | DbPatch_Command_Patch_Abstract
getPatchDirectory ( ) : string | boolean
getPatchPrefix ( ) : string
getPatches ( string $branch, null | integer $searchPatchNumber = null ) : array
getWriter ( ) : DbPatch_Core_Writer | null
init ( ) : DbPatch_Command_Abstract
setConfig ( Zend_Config | Zend_Config_Ini | Zend_Config_Xml $config ) : DbPatch_Command_Abstract
setConsole ( DbPatch_Core_Console $console ) : DbPatch_Command_Abstract
setDb ( DbPatch_Core_Db $db ) : DbPatch_Command_Abstract
setOptions ( $options ) : void
setWriter ( DbPatch_Core_Writer $writer ) : DbPatch_Command_Abstract
trimTrailingSlashes ( string $str ) : string Remove trailing slash from string

Protected Methods

Method Description
addToChangelog ( array $patchFile, string $description = null ) : void Store patchfile entry to the changelog table
changelogExists ( ) : boolean Checks if the changelog table is present in the database
createChangelog ( ) : boolean Try to create the changelog table
detectBranches ( ) : array Detect the different branches that are used in the patch dir the default branch is always returned
dumpDatabase ( string $filename, $noData = false ) : boolean Dump database
getDumpFilename ( ) : string Create dump filename
isPatchApplied ( integer $patchNumber, string $branch ) : boolean Check if the passed patch number can be found in the changelog table for the specified branch
showHelp ( string $command = null ) : void Show help options for a given command
updateColumnType ( ) Check column types return void
validateChangelog ( ) : boolean Validate if the changelog is present in the database if not try to create the table

Method Details

addToChangelog() protected method

Store patchfile entry to the changelog table
protected addToChangelog ( array $patchFile, string $description = null ) : void
$patchFile array
$description string
return void

changelogExists() protected method

Checks if the changelog table is present in the database
protected changelogExists ( ) : boolean
return boolean

createChangelog() protected method

Try to create the changelog table
protected createChangelog ( ) : boolean
return boolean

detectBranches() protected method

Detect the different branches that are used in the patch dir the default branch is always returned
protected detectBranches ( ) : array
return array

dumpDatabase() protected method

Dump database
protected dumpDatabase ( string $filename, $noData = false ) : boolean
$filename string
return boolean

execute() abstract public method

abstract public execute ( ) : void
return void

getBranch() public method

public getBranch ( ) : string
return string

getConfig() public method

public getConfig ( ) : null | Zend_Config | Zend_Config_Ini | Zend_Config_Xml
return null | Zend_Config | Zend_Config_Ini | Zend_Config_Xml

getConsole() public method

public getConsole ( ) : DbPatch_Core_Console | null
return DbPatch_Core_Console | null

getDb() public method

public getDb ( ) : null | Zend_Db_Adapter_Abstract
return null | Zend_Db_Adapter_Abstract

getDumpFilename() protected method

Create dump filename
protected getDumpFilename ( ) : string
return string

getOptions() public method

public getOptions ( ) : array
return array

getPatch() public method

public getPatch ( integer $patchNumber, string $branch ) : boolean | DbPatch_Command_Patch_Abstract
$patchNumber integer
$branch string
return boolean | DbPatch_Command_Patch_Abstract

getPatchDirectory() public method

public getPatchDirectory ( ) : string | boolean
return string | boolean

getPatchPrefix() public method

public getPatchPrefix ( ) : string
return string

getPatches() public method

public getPatches ( string $branch, null | integer $searchPatchNumber = null ) : array
$branch string
$searchPatchNumber null | integer
return array

getWriter() public method

public getWriter ( ) : DbPatch_Core_Writer | null
return DbPatch_Core_Writer | null

init() public method

public init ( ) : DbPatch_Command_Abstract
return DbPatch_Command_Abstract

isPatchApplied() protected method

Check if the passed patch number can be found in the changelog table for the specified branch
protected isPatchApplied ( integer $patchNumber, string $branch ) : boolean
$patchNumber integer
$branch string
return boolean $result true if patch already applied; false if not

setConfig() public method

public setConfig ( Zend_Config | Zend_Config_Ini | Zend_Config_Xml $config ) : DbPatch_Command_Abstract
$config Zend_Config | Zend_Config_Ini | Zend_Config_Xml
return DbPatch_Command_Abstract

setConsole() public method

public setConsole ( DbPatch_Core_Console $console ) : DbPatch_Command_Abstract
$console DbPatch_Core_Console
return DbPatch_Command_Abstract

setDb() public method

public setDb ( DbPatch_Core_Db $db ) : DbPatch_Command_Abstract
$db DbPatch_Core_Db
return DbPatch_Command_Abstract

setOptions() public method

public setOptions ( $options ) : void
$options
return void

setWriter() public method

public setWriter ( DbPatch_Core_Writer $writer ) : DbPatch_Command_Abstract
$writer DbPatch_Core_Writer
return DbPatch_Command_Abstract

showHelp() protected method

Show help options for a given command
protected showHelp ( string $command = null ) : void
$command string
return void

trimTrailingSlashes() public method

Remove trailing slash from string
public trimTrailingSlashes ( string $str ) : string
$str string String
return string

updateColumnType() protected method

Check column types return void
protected updateColumnType ( )

validateChangelog() protected method

Validate if the changelog is present in the database if not try to create the table
protected validateChangelog ( ) : boolean
return boolean

Property Details

$config protected property

protected Zend_Config|Zend_Config_Ini|Zend_Config_Xml $config
return Zend_Config | Zend_Config_Ini | Zend_Config_Xml

$console protected property

protected DbPatch_Core_Console $console
return DbPatch_Core_Console

$db protected property

protected DbPatch_Core_Db $db
return DbPatch_Core_Db

$options protected property

protected array $options
return array

$writer protected property

protected DbPatch_Core_Writer $writer
return DbPatch_Core_Writer