PHP Класс Bake\Shell\Task\ModelTask

Наследование: extends Bake\Shell\Task\BakeTask
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$pathFragment string path to Model directory
$skipTables array Tables to skip when running all()
$tasks array tasks

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

Свойство Тип Описание
$_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