Class FixtureTask
Task class for creating and updating fixtures files.
- AppShell
- BakeTask
- FixtureTask
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/FixtureTask.php
Properties summary
-
$_Schema
protected -
$path
publicpath to fixtures directorystring
-
$tasks
publicTasks to be loaded by this Taskarray
Inherited Properties
Method Summary
- __construct() publicOverride initialize
- _generateRecords() protectedGenerate String representation of Records
- _generateSchema() protectedGenerates 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() protectedInteractive baking function
- _makeRecordString() protectedConvert a $records array into a string.
- all() publicBake All the Fixtures at once. Will only bake fixtures for models that exist.
- bake() publicAssembles and writes a Fixture file
- execute() public
Execution method always used for tasks Handles dispatching to interactive, named, or all processes.
- generateFixtureFile() publicGenerate the fixture file, and write to disk
- getOptionParser() publicGets the option parser instance and configures it.
- getPath() publicGet the path to the fixtures.
- importOptions() publicInteracts with the User to setup an array of import options. For a fixture.
Method Detail
__construct()source 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()source 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
arrayArray of records to use in the fixture.
_generateSchema()source protected
_generateSchema( array $tableInfo )
Generates a string representation of a schema.
Parameters
- array
$tableInfo
- Table schema array
Returns
stringfields definitions
_getRecordsFromTable()source 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
arrayArray of records.
_makeRecordString()source protected
_makeRecordString( array $records )
Convert a $records array into a string.
Parameters
- array
$records
- Array of records to be converted to string
Returns
stringA string value of the $records array.
all()source public
all( )
Bake All the Fixtures at once. Will only bake fixtures for models that exist.
bake()source 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
string|nullBaked fixture content, otherwise null.
execute()source public
execute( )
Execution method always used for tasks Handles dispatching to interactive, named, or all processes.
Overrides
BakeTask::execute()
generateFixtureFile()source 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
stringContent saved into fixture file.
getOptionParser()source public
getOptionParser( )
Gets the option parser instance and configures it.
Returns
ConsoleOptionParser
getPath()source public
getPath( )
Get the path to the fixtures.
Returns
stringPath for the fixtures
Overrides
BakeTask::getPath()
importOptions()source 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
arrayArray of import options.
Methods inherited from BakeTask
startup()source public
startup( )
Disable caching and enable debug for baking. This forces the most current database schema to be used.
Properties detail
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-FixtureTask.html