Class FixtureTask
Task class for creating and updating fixtures files.
- AppShell
- BakeTask
- FixtureTask
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/FixtureTask.php
Properties summary
Inherited Properties
Method Summary
-
__construct() public
Override initialize -
_generateRecords() protected
Generate String representation of Records -
_generateSchema() protected
Generates a string representation of a schema. -
_getRecordsFromTable() protected
Interact with the user to get a custom SQL condition and use that to extract data to build a fixture.
-
_interactive() protected
Interactive baking function -
_makeRecordString() protected
Convert a $records array into a string. -
all() public
Bake All the Fixtures at once. Will only bake fixtures for models that exist. -
bake() public
Assembles and writes a Fixture file -
execute() public
Execution method always used for tasks Handles dispatching to interactive, named, or all processes.
-
generateFixtureFile() public
Generate the fixture file, and write to disk -
getOptionParser() public
Gets the option parser instance and configures it. -
getPath() public
Get the path to the fixtures. -
importOptions() public
Interacts with the User to setup an array of import options. For a fixture.
Method Detail
__construct() public ¶
__construct( ConsoleOutput
$stdout = null , ConsoleOutput
$stderr = null , ConsoleInput
$stdin = null )
Override initialize
Parameters
-
ConsoleOutput
$stdout optional null - A ConsoleOutput object for stdout.
-
ConsoleOutput
$stderr optional null - A ConsoleOutput object for stderr.
-
ConsoleInput
$stdin optional null - A ConsoleInput object for stdin.
_generateRecords() protected ¶
_generateRecords( array $tableInfo , integer $recordCount = 1 )
Generate String representation of Records
Parameters
- array $tableInfo
- Table schema array
- integer $recordCount optional 1
- The number of records to generate.
Returns
Array of records to use in the fixture.
_generateSchema() protected ¶
_generateSchema( array $tableInfo )
Generates a string representation of a schema.
Parameters
- array $tableInfo
- Table schema array
Returns
fields definitions
_getRecordsFromTable() protected ¶
_getRecordsFromTable( string $modelName , string $useTable = null )
Interact with the user to get a custom SQL condition and use that to extract data to build a fixture.
Parameters
- string $modelName
- name of the model to take records from.
- string $useTable optional null
- Name of table to use.
Returns
Array of records.
_makeRecordString() protected ¶
_makeRecordString( array $records )
Convert a $records array into a string.
Parameters
- array $records
- Array of records to be converted to string
Returns
A string value of the $records array.
bake() public ¶
bake( string $model , string $useTable = false , array $importOptions = array() )
Assembles and writes a Fixture file
Parameters
- string $model
- Name of model to bake.
- string $useTable optional false
- Name of table to use.
- array $importOptions optional array()
- Options for public $import
Returns
Baked fixture content, otherwise null.
execute() public ¶
execute( )
Execution method always used for tasks Handles dispatching to interactive, named, or all processes.
Overrides
generateFixtureFile() public ¶
generateFixtureFile( string $model , string $otherVars )
Generate the fixture file, and write to disk
Parameters
- string $model
- name of the model being generated
- string $otherVars
- Contents of the fixture file.
Returns
Content saved into fixture file.
importOptions() public ¶
importOptions( string $modelName )
Interacts with the User to setup an array of import options. For a fixture.
Parameters
- string $modelName
- Name of model you are dealing with.
Returns
Array of import options.