CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.4 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.4
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • BakeTask
  • ControllerTask
  • DbConfigTask
  • ExtractTask
  • FixtureTask
  • ModelTask
  • PluginTask
  • ProjectTask
  • TemplateTask
  • TestTask
  • ViewTask

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. (http://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/FixtureTask.php

Properties summary

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

Inherited Properties

  • connection, interactive, plugin

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 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
    get the option parser.
  • 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
Returns
array
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
string
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
Array of records.

_interactive() protected ¶

_interactive( )

Interactive baking function

_makeRecordString() protected ¶

_makeRecordString( array $records )

Convert a $records array into a a string.

Parameters
array $records
Array of records to be converted to string
Returns
string
A string value of the $records array.

all() public ¶

all( )

Bake All the Fixtures at once. Will only bake fixtures for models that exist.

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
string
Baked fixture content

execute() public ¶

execute( )

Execution method always used for tasks Handles dispatching to interactive, named, or all processes.

Overrides
BakeTask::execute()

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
string
Content saved into fixture file.

getOptionParser() public ¶

getOptionParser( )

get the option parser.

getPath() public ¶

getPath( )

Get the path to the fixtures.

Returns
string
Path for the fixtures
Overrides
BakeTask::getPath()

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
Array of import options.

Methods inherited from BakeTask

startup() public ¶

startup( )

Disable caching and enable debug for baking. This forces the most current database schema to be used.

Properties detail

$_Schema ¶

protected CakeSchema

Schema instance

null

$path ¶

public string

path to fixtures directory

null

$tasks ¶

public array

Tasks to be loaded by this Task

array('DbConfig', 'Model', 'Template')
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs