PHP Class LazyRecord\Schema\DeclareSchema

Inheritance: extends SchemaBase, implements LazyRecord\Schema\SchemaInterface
Afficher le fichier Open project: corneltek/lazyrecord Class Usage Examples

Méthodes publiques

Свойство Type Description
$collectionInterfaceClasses string[]
$collectionTraitClasses string[]
$enableColumnAccessors
$indexes
$modelInterfaceClasses string[]
$modelTraitClasses string[]
$onDelete
$onUpdate

Méthodes publiques

Méthode Description
__construct ( array $options = [] ) Constructor of declare schema.
__toString ( )
addCollectionInterface ( $iface ) Implement interface in collection class.
addCollectionTrait ( $traitClass ) : ClassTemplate\ClassTrait Use trait for the model class.
addColumn ( DeclareColumn $column ) : DeclareColumn Add column object into the column list.
addModelInterface ( $iface ) Implement interface in model class.
addModelTrait ( $traitClass ) : ClassTemplate\ClassTrait Use trait for the model class.
addSeed ( string $seed ) Add seed class.
belongsTo ( $accessor, string $foreignClass, string $foreignColumn = 'id', string $selfColumn = null ) define self primary key to foreign key reference.
column ( string $name, string $class = 'LazyRecord\Schema\DeclareColumn' ) : DeclareColumn Define new column object.
dump ( )
export ( )
findPrimaryKey ( ) : string Find primary key from columns.
findPrimaryKeyColumn ( ) : DeclareColumn Find primary key column object from columns.
getClassFileName ( )
getClassName ( )
getCollectionInterfaces ( ) : string[]
getCollectionTraitClasses ( ) : string[]
getColumn ( string $name ) 'getColumn' gets the column object by the given column name.
getColumnLabels ( $includeVirtual = false )
getColumnNames ( boolean $includeVirtual = false ) : string[]
getColumns ( $includeVirtual = false )
getDirectory ( ) : string Get directory from current schema object.
getIndexQueries ( ) : SQLBuilder\Universal\Query\CreateIndexQuery[]
getLabel ( )
getModelClass ( ) : string Get model class name of this schema.
getModelInterfaces ( ) : string[]
getModelTraitClasses ( ) : string[]
getModificationTime ( ) : integer Return the modification time of this schema definition class.
getMsgIds ( )
getPrimaryKey ( ) : string Get the primary key column name.
getReadSourceId ( )
getRelatedClassPath ( string $class ) : string Get the related class file path by the given class name.
getShortClassName ( )
getTable ( ) : string Get the table name of this schema class.
getWriteSourceId ( )
hasColumn ( string $name ) : boolean hasColumn method returns true if a column name is defined.
hasMany ( )
hasOne ( string $accessor, string $foreignClass, string $foreignColumn = null, string $selfColumn ) has-one relationship.
insertColumn ( DeclareColumn $column ) Insert column object at the begining of the column list.
isNewerThanFile ( string $path ) : boolean isNewerThanFile returns true if the schema file is newer than a file.
label ( string $label ) Define schema label.
many ( string $accessor, string $foreignClass, string $foreignColumn, string $selfColumn ) Add has-many relation.
manyToMany ( string $accessor, string $relationId, string $foreignRelationId )
mixin ( string $class, array $options = [] ) Mixin.
onDelete ( string $action ) onDelete defines a software trigger of delete action.
onUpdate ( $action ) onUpdate defines a software trigger of update action.
readFrom ( string $id ) set data source for read.
removeColumn ( $columnName )
requireProxyFileUpdate ( ) : boolean requireProxyFileUpdate returns true if the schema proxy file is out of date.
schema ( )
seeds ( ) : DeclareSchema 'seeds' helps you define seed classes.
table ( string $table ) Define table name.
using ( string $id ) set data source for both write and read.
writeTo ( string $id ) set data source for write.

Méthodes protégées

Méthode Description
_classnameToTable ( ) : string Convert current model name to a class name.
_modelClassToLabel ( )
build ( array $options = [] ) Build schema build the schema by running the "schema" method.
disableColumnAccessors ( ) SchemaGenerator generates column accessor methods from the column definition automatically.
getCurrentSchemaClass ( )
helper ( string $helperName, array $arguments = [] ) : BaseHelper Invode helper.
index ( $name, $columns = null, $using = null ) : SQLBuilder\Universal\Query\CreateIndexQuery 'index' method helps you define index queries.
insertAutoIdPrimaryColumn ( string $name = 'id', string $columnType = 'integer' ) Insert a primary key column with auto increment.
resolveSchemaClass ( $class )

Method Details

__construct() public méthode

The constructor calls build method to build the schema information.
public __construct ( array $options = [] )
$options array

__toString() public méthode

public __toString ( )

_classnameToTable() protected méthode

Convert current model name to a class name.
protected _classnameToTable ( ) : string
Résultat string table name

_modelClassToLabel() protected méthode

protected _modelClassToLabel ( )

addCollectionInterface() public méthode

Implement interface in collection class.
public addCollectionInterface ( $iface )

addCollectionTrait() public méthode

Use trait for the model class.
public addCollectionTrait ( $traitClass ) : ClassTemplate\ClassTrait
Résultat ClassTemplate\ClassTrait object

addColumn() public méthode

Add column object into the column list.
public addColumn ( DeclareColumn $column ) : DeclareColumn
$column DeclareColumn
Résultat DeclareColumn

addModelInterface() public méthode

Implement interface in model class.
public addModelInterface ( $iface )

addModelTrait() public méthode

Use trait for the model class.
public addModelTrait ( $traitClass ) : ClassTemplate\ClassTrait
Résultat ClassTemplate\ClassTrait object

addSeed() public méthode

Add seed class.
public addSeed ( string $seed )
$seed string

belongsTo() public méthode

comments( post_id => author.comment_id ) $post->publisher
public belongsTo ( $accessor, string $foreignClass, string $foreignColumn = 'id', string $selfColumn = null )
$foreignClass string foreign schema class.
$foreignColumn string foreign reference schema column.
$selfColumn string self column name

build() protected méthode

The post process find the primary key from the built columns And insert the auto-increment primary is auto_id config is enabled.
protected build ( array $options = [] )
$options array

column() public méthode

Define new column object.
public column ( string $name, string $class = 'LazyRecord\Schema\DeclareColumn' ) : DeclareColumn
$name string column name
$class string column class name
Résultat DeclareColumn

disableColumnAccessors() protected méthode

If you don't want these accessors to be generated, you may simply call 'disableColumnAccessors'
protected disableColumnAccessors ( )

dump() public méthode

public dump ( )

export() public méthode

public export ( )

findPrimaryKey() public méthode

This method will be called after building schema information to save the primary key name
public findPrimaryKey ( ) : string
Résultat string primary key

findPrimaryKeyColumn() public méthode

This method will be called after building schema information to save the primary key name
public findPrimaryKeyColumn ( ) : DeclareColumn
Résultat DeclareColumn

getClassFileName() public méthode

public getClassFileName ( )

getClassName() public méthode

public getClassName ( )

getCollectionInterfaces() public méthode

public getCollectionInterfaces ( ) : string[]
Résultat string[]

getCollectionTraitClasses() public méthode

public getCollectionTraitClasses ( ) : string[]
Résultat string[]

getColumn() public méthode

'getColumn' gets the column object by the given column name.
public getColumn ( string $name )
$name string

getColumnLabels() public méthode

public getColumnLabels ( $includeVirtual = false )

getColumnNames() public méthode

public getColumnNames ( boolean $includeVirtual = false ) : string[]
$includeVirtual boolean
Résultat string[]

getColumns() public méthode

public getColumns ( $includeVirtual = false )

getCurrentSchemaClass() protected méthode

protected getCurrentSchemaClass ( )

getDirectory() public méthode

Get directory from current schema object.
public getDirectory ( ) : string
Résultat string path

getIndexQueries() public méthode

public getIndexQueries ( ) : SQLBuilder\Universal\Query\CreateIndexQuery[]
Résultat SQLBuilder\Universal\Query\CreateIndexQuery[]

getLabel() public méthode

public getLabel ( )

getModelClass() public méthode

Get model class name of this schema.
public getModelClass ( ) : string
Résultat string model class name

getModelInterfaces() public méthode

public getModelInterfaces ( ) : string[]
Résultat string[]

getModelTraitClasses() public méthode

public getModelTraitClasses ( ) : string[]
Résultat string[]

getModificationTime() public méthode

Return the modification time of this schema definition class.
public getModificationTime ( ) : integer
Résultat integer timestamp

getMsgIds() public méthode

public getMsgIds ( )

getPrimaryKey() public méthode

Get the primary key column name.
public getPrimaryKey ( ) : string
Résultat string primary key column name

getReadSourceId() public méthode

public getReadSourceId ( )

getRelatedClassPath() public méthode

Get the related class file path by the given class name.
public getRelatedClassPath ( string $class ) : string
$class string the scheam related class name
Résultat string the class filepath.

getShortClassName() public méthode

public getShortClassName ( )

getTable() public méthode

Get the table name of this schema class.
public getTable ( ) : string
Résultat string

getWriteSourceId() public méthode

public getWriteSourceId ( )

hasColumn() public méthode

hasColumn method returns true if a column name is defined.
public hasColumn ( string $name ) : boolean
$name string
Résultat boolean

hasMany() public méthode

public hasMany ( )

hasOne() public méthode

model( post_id => post )
public hasOne ( string $accessor, string $foreignClass, string $foreignColumn = null, string $selfColumn )
$accessor string accessor name.
$foreignClass string foreign schema class
$foreignColumn string foreign schema column
$selfColumn string self schema column

helper() protected méthode

Invode helper.
protected helper ( string $helperName, array $arguments = [] ) : BaseHelper
$helperName string
$arguments array indexed array, passed to the init function of helper class.
Résultat LazyRecord\Schema\Helper\BaseHelper

index() protected méthode

'index' method helps you define index queries.
protected index ( $name, $columns = null, $using = null ) : SQLBuilder\Universal\Query\CreateIndexQuery
Résultat SQLBuilder\Universal\Query\CreateIndexQuery

insertAutoIdPrimaryColumn() protected méthode

Insert a primary key column with auto increment.
protected insertAutoIdPrimaryColumn ( string $name = 'id', string $columnType = 'integer' )
$name string default to 'id'
$columnType string 'int', 'smallint', 'bigint' ...

insertColumn() public méthode

Insert column object at the begining of the column list.
public insertColumn ( DeclareColumn $column )
$column DeclareColumn

isNewerThanFile() public méthode

isNewerThanFile returns true if the schema file is newer than a file.
public isNewerThanFile ( string $path ) : boolean
$path string
Résultat boolean

label() public méthode

Define schema label.
public label ( string $label )
$label string label name

many() public méthode

TODO: provide a relationship object to handle sush operation, that will be: $this->hasMany('books','id') ->from('App_Model_Book','author_id')
public many ( string $accessor, string $foreignClass, string $foreignColumn, string $selfColumn )
$accessor string accessor name.
$foreignClass string foreign schema class
$foreignColumn string foreign schema column
$selfColumn string self schema column

manyToMany() public méthode

public manyToMany ( string $accessor, string $relationId, string $foreignRelationId )
$accessor string accessor name.
$relationId string a hasMany relationship.
$foreignRelationId string foreign relation id.

mixin() public méthode

Availabel mixins $this->mixin('Metadata' , array( options ) ); $this->mixin('I18n');
public mixin ( string $class, array $options = [] )
$class string mixin class name
$options array

onDelete() public méthode

onDelete defines a software trigger of delete action.
public onDelete ( string $action )
$action string Currently for 'cascade'

onUpdate() public méthode

onUpdate defines a software trigger of update action.
public onUpdate ( $action )

readFrom() public méthode

set data source for read.
public readFrom ( string $id )
$id string data source id

removeColumn() public méthode

public removeColumn ( $columnName )

requireProxyFileUpdate() public méthode

requireProxyFileUpdate returns true if the schema proxy file is out of date.
public requireProxyFileUpdate ( ) : boolean
Résultat boolean

resolveSchemaClass() protected méthode

protected resolveSchemaClass ( $class )

schema() public méthode

public schema ( )

seeds() public méthode

$this->seeds('User\\Seed','Data\\Seed');
public seeds ( ) : DeclareSchema
Résultat DeclareSchema

table() public méthode

Define table name.
public table ( string $table )
$table string table name

using() public méthode

set data source for both write and read.
public using ( string $id )
$id string data source id

writeTo() public méthode

set data source for write.
public writeTo ( string $id )
$id string data source id

Property Details

$collectionInterfaceClasses public_oe property

public string[] $collectionInterfaceClasses
Résultat string[]

$collectionTraitClasses public_oe property

public string[] $collectionTraitClasses
Résultat string[]

$enableColumnAccessors public_oe property

public $enableColumnAccessors

$indexes public_oe property

public $indexes

$modelInterfaceClasses public_oe property

public string[] $modelInterfaceClasses
Résultat string[]

$modelTraitClasses public_oe property

public string[] $modelTraitClasses
Résultat string[]

$onDelete public_oe property

public $onDelete

$onUpdate public_oe property

public $onUpdate