Class FixtureTask

Task class for creating and updating fixtures files.

AppShell
Extended by BakeTask
Extended by FixtureTask
Package: Cake\Console\Command\Task
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/FixtureTask.php

Properties summary

  • $_Schema protected
    Schema instance
  • $path public
    string
    path to fixtures directory
  • $tasks public
    array
    Tasks to be loaded by this Task

Inherited Properties

Method Summary

  • __construct() public
    Override initialize
  • _generateRecords() protected
    Generate String representation of Records
  • _generateSchema() protected
    Generates a string representation of a schema.
  • 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
  • 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.

  • Generate the fixture file, and write to disk
  • Gets the option parser instance and configures it.
  • getPath() public
    Get the path to the fixtures.
  • Interacts 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

array
Array 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

string
fields 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

array
Array of records.

_interactive()source protected

_interactive( )

Interactive baking function

_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

string
A 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|null
Baked 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

string
Content 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

string
Path 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

array
Array 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

$_Schemasource

protected CakeSchema

Schema instance

null

$pathsource

public string

path to fixtures directory

null

$taskssource

public array

Tasks to be loaded by this Task

array('DbConfig', 'Model', 'Template')

© 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