PHP 클래스 Bake\Shell\Task\ModelTask

상속: extends Bake\Shell\Task\BakeTask
파일 보기 프로젝트 열기: cakephp/bake 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$pathFragment string path to Model directory
$skipTables array Tables to skip when running all()
$tasks array tasks

보호된 프로퍼티들

프로퍼티 타입 설명
$_modelNames array Holds the model names
$_tables array Holds tables found on connection.
$_validations array Holds validation method map.

공개 메소드들

메소드 설명
all ( ) : void Bake all models at once.
applyAssociations ( Table $model, array $associations ) : void Sync the in memory table object.
bake ( string $name ) : void Generate code for the given model name.
bakeEntity ( Table $model, array $data = [] ) : string | null Bake an entity class.
bakeFixture ( string $className, string | null $useTable = null ) : void Interact with FixtureTask to automatically bake fixtures when baking models.
bakeTable ( Table $model, array $data = [] ) : string | null Bake a table class.
bakeTest ( string $className ) : string | null Assembles and writes a unit test file
fieldValidation ( Cake\Database\Schema\Table $schema, string $fieldName, array $metaData, string $primaryKey ) : array Does individual field validation handling.
findBelongsTo ( Table $model, array $associations ) : array Find belongsTo relations and add them to the associations list.
findBelongsToMany ( Table $model, array $associations ) : array Find the BelongsToMany relations and add them to associations list
findHasMany ( Table $model, array $associations ) : array Find the hasMany relations and add them to associations list
findTableReferencedBy ( Cake\Database\Schema\Table $schema, string $keyField ) : string | null find the table, if any, actually referenced by the passed key field.
getAssociations ( Table $table ) : array Get the array of associations to generate.
getBehaviors ( Table $model ) : array Get behaviors
getCounterCache ( Table $model ) : array Get CounterCaches
getDisplayField ( Table $model ) : string Get the display field from the model or parameters
getEntityPropertySchema ( Table $model ) : array Returns an entity property "schema".
getFields ( ) : array | boolean | null Evaluates the fields and no-fields options, and returns if, and which fields should be made accessible.
getHiddenFields ( Table $model ) : array Get the hidden fields from a model.
getOptionParser ( ) : Cake\Console\ConsoleOptionParser Gets the option parser instance and configures it.
getPrimaryKey ( Table $model ) : array Get the primary key field from the model or parameters
getRules ( Table $model, array $associations ) : array Generate default rules checker.
getTable ( string $name ) : string Get the table name for the model being baked.
getTableContext ( Table $tableObject, string $table, string $name ) : array Get table context for baking a given table.
getTableObject ( string $className, string $table ) : Table Get a model object for a class name.
getValidation ( Table $model, array $associations = [] ) : array Generate default validation rules.
listAll ( ) : array Outputs the a list of possible models or controllers from database
listUnskipped ( ) : array Outputs the a list of unskipped models or controllers from database
main ( string | null $name = null ) : void Execution method always used for tasks

보호된 메소드들

메소드 설명
_getAllTables ( ) : array Get an Array of all the tables in the supplied connection will halt the script if no tables are found.
_getPrefix ( ) : string Models never have routing prefixes applied.

메소드 상세

_getAllTables() 보호된 메소드

Get an Array of all the tables in the supplied connection will halt the script if no tables are found.
protected _getAllTables ( ) : array
리턴 array Array of tables in the database.

_getPrefix() 보호된 메소드

Models never have routing prefixes applied.
protected _getPrefix ( ) : string
리턴 string

all() 공개 메소드

Bake all models at once.
public all ( ) : void
리턴 void

applyAssociations() 공개 메소드

Composer's class cache prevents us from loading the newly generated class. Applying associations if we have a generic table object means fields will be detected correctly.
public applyAssociations ( Table $model, array $associations ) : void
$model Cake\ORM\Table The table to apply associations to.
$associations array The associations to append.
리턴 void

bake() 공개 메소드

Generate code for the given model name.
public bake ( string $name ) : void
$name string The model name to generate.
리턴 void

bakeEntity() 공개 메소드

Bake an entity class.
public bakeEntity ( Table $model, array $data = [] ) : string | null
$model Cake\ORM\Table Model name or object
$data array An array to use to generate the Table
리턴 string | null

bakeFixture() 공개 메소드

Interact with FixtureTask to automatically bake fixtures when baking models.
또한 보기: FixtureTask::bake
public bakeFixture ( string $className, string | null $useTable = null ) : void
$className string Name of class to bake fixture for
$useTable string | null Optional table name for fixture to use.
리턴 void

bakeTable() 공개 메소드

Bake a table class.
public bakeTable ( Table $model, array $data = [] ) : string | null
$model Cake\ORM\Table Model name or object
$data array An array to use to generate the Table
리턴 string | null

bakeTest() 공개 메소드

Assembles and writes a unit test file
public bakeTest ( string $className ) : string | null
$className string Model class name
리턴 string | null

fieldValidation() 공개 메소드

Does individual field validation handling.
public fieldValidation ( Cake\Database\Schema\Table $schema, string $fieldName, array $metaData, string $primaryKey ) : array
$schema Cake\Database\Schema\Table The table schema for the current field.
$fieldName string Name of field to be validated.
$metaData array metadata for field
$primaryKey string The primary key field
리턴 array Array of validation for the field.

findBelongsTo() 공개 메소드

Find belongsTo relations and add them to the associations list.
public findBelongsTo ( Table $model, array $associations ) : array
$model Cake\ORM\Table Database\Table instance of table being generated.
$associations array Array of in progress associations
리턴 array Associations with belongsTo added in.

findBelongsToMany() 공개 메소드

Find the BelongsToMany relations and add them to associations list
public findBelongsToMany ( Table $model, array $associations ) : array
$model Cake\ORM\Table Model instance being generated
$associations array Array of in-progress associations
리턴 array Associations with belongsToMany added in.

findHasMany() 공개 메소드

Find the hasMany relations and add them to associations list
public findHasMany ( Table $model, array $associations ) : array
$model Cake\ORM\Table Model instance being generated
$associations array Array of in progress associations
리턴 array Associations with hasMany added in.

findTableReferencedBy() 공개 메소드

Search tables in db for keyField; if found search key constraints for the table to which it refers.
public findTableReferencedBy ( Cake\Database\Schema\Table $schema, string $keyField ) : string | null
$schema Cake\Database\Schema\Table The table schema to find a constraint for.
$keyField string The field to check for a constraint.
리턴 string | null Either the referenced table or null if the field has no constraints.

getAssociations() 공개 메소드

Get the array of associations to generate.
public getAssociations ( Table $table ) : array
$table Cake\ORM\Table The table to get associations for.
리턴 array

getBehaviors() 공개 메소드

Get behaviors
public getBehaviors ( Table $model ) : array
$model Cake\ORM\Table The model to generate behaviors for.
리턴 array Behaviors

getCounterCache() 공개 메소드

Get CounterCaches
public getCounterCache ( Table $model ) : array
$model Cake\ORM\Table The table to get counter cache fields for.
리턴 array CounterCache configurations

getDisplayField() 공개 메소드

Get the display field from the model or parameters
public getDisplayField ( Table $model ) : string
$model Cake\ORM\Table The model to introspect.
리턴 string

getEntityPropertySchema() 공개 메소드

The schema is an associative array, using the property names as keys, and information about the property as the value. The value part consists of at least two keys: - kind: The kind of property, either column, which indicates that the property stems from a database column, or association, which identifies a property that is generated for an associated table. - type: The type of the property value. For the column kind this is the database type associated with the column, and for the association type it's the FQN of the entity class for the associated table. For association properties an additional key will be available - association: Holds an instance of the corresponding association class.
public getEntityPropertySchema ( Table $model ) : array
$model Cake\ORM\Table The model to introspect.
리턴 array The property schema

getFields() 공개 메소드

Evaluates the fields and no-fields options, and returns if, and which fields should be made accessible.
public getFields ( ) : array | boolean | null
리턴 array | boolean | null Either an array of fields, `false` in case the no-fields option is used, or `null` if none of the field options is used.

getHiddenFields() 공개 메소드

Uses the hidden and no-hidden options.
public getHiddenFields ( Table $model ) : array
$model Cake\ORM\Table The model to introspect.
리턴 array The columns to make accessible

getOptionParser() 공개 메소드

Gets the option parser instance and configures it.
public getOptionParser ( ) : Cake\Console\ConsoleOptionParser
리턴 Cake\Console\ConsoleOptionParser

getPrimaryKey() 공개 메소드

Get the primary key field from the model or parameters
public getPrimaryKey ( Table $model ) : array
$model Cake\ORM\Table The model to introspect.
리턴 array The columns in the primary key

getRules() 공개 메소드

Generate default rules checker.
public getRules ( Table $model, array $associations ) : array
$model Cake\ORM\Table The model to introspect.
$associations array The associations for the model.
리턴 array The rules to be applied.

getTable() 공개 메소드

Uses the table option if it is set.
public getTable ( string $name ) : string
$name string Table name
리턴 string

getTableContext() 공개 메소드

Get table context for baking a given table.
public getTableContext ( Table $tableObject, string $table, string $name ) : array
$tableObject Cake\ORM\Table The model name to generate.
$table string The table name for the model being baked.
$name string The model name to generate.
리턴 array

getTableObject() 공개 메소드

Get a model object for a class name.
public getTableObject ( string $className, string $table ) : Table
$className string Name of class you want model to be.
$table string Table name
리턴 Cake\ORM\Table Table instance

getValidation() 공개 메소드

Generate default validation rules.
public getValidation ( Table $model, array $associations = [] ) : array
$model Cake\ORM\Table The model to introspect.
$associations array The associations list.
리턴 array The validation rules.

listAll() 공개 메소드

Outputs the a list of possible models or controllers from database
public listAll ( ) : array
리턴 array

listUnskipped() 공개 메소드

Outputs the a list of unskipped models or controllers from database
public listUnskipped ( ) : array
리턴 array

main() 공개 메소드

Execution method always used for tasks
public main ( string | null $name = null ) : void
$name string | null The name of the table to bake.
리턴 void

프로퍼티 상세

$_modelNames 보호되어 있는 프로퍼티

Holds the model names
protected array $_modelNames
리턴 array

$_tables 보호되어 있는 프로퍼티

Holds tables found on connection.
protected array $_tables
리턴 array

$_validations 보호되어 있는 프로퍼티

Holds validation method map.
protected array $_validations
리턴 array

$pathFragment 공개적으로 프로퍼티

path to Model directory
public string $pathFragment
리턴 string

$skipTables 공개적으로 프로퍼티

Tables to skip when running all()
public array $skipTables
리턴 array

$tasks 공개적으로 프로퍼티

tasks
public array $tasks
리턴 array