On this page
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 instance$_Schemaprotected
- 
    $pathpublicpath to fixtures directorystring
- 
    $taskspublicTasks 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() protectedInteract 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() publicExecution 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- $stdoutoptional null
- A ConsoleOutput object for stdout.
- ConsoleOutput- $stderroptional null
- A ConsoleOutput object for stderr.
- ConsoleInput- $stdinoptional 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 $recordCountoptional 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 $useTableoptional 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 $useTableoptional false
- Name of table to use.
- 
     array $importOptionsoptional 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
ConsoleOptionParsergetPath()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