class Doctrine_Data_Import extends Doctrine_Data (View source)

Doctrine_Data_Import

Properties

protected string $_formats formats from Doctrine_Data
protected string $_format format from Doctrine_Data
protected string $_directory directory from Doctrine_Data
protected string $_models models from Doctrine_Data
protected string $_exportIndividualFiles _exportIndividualFiles from Doctrine_Data
protected array $_importedObjects Array of imported objects for processing and saving
protected array $_rows Array of the raw data parsed from yaml

Methods

void
setFormat(string $format)

setFormat

void
getFormat()

getFormat

void
getFormats()

getFormats

void
setDirectory($directory)

setDirectory

void
getDirectory()

getDirectory

void
setModels(string $models)

setModels

void
getModels()

getModels

bool
exportIndividualFiles($bool = null)

_exportIndividualFiles

void
exportData(string $directory, string $format = 'yml', string $models = array(), string $_exportIndividualFiles = false)

exportData

void
importData($directory, $format = 'yml', $models = array(), $append = false)

importData

void
isRelation(Doctrine_Record $record, $fieldName)

isRelation

void
purge(string $models = null)

purge

void
__construct(string $directory = null)

Optionally pass the directory/path to the yaml for importing

array
doParsing()

Do the parsing of the yaml files and return the final parsed array

void
doImport($append = false)

Do the importing of the data parsed from the fixtures

void
_buildRows($className, $data)

Recursively loop over all data fixtures and build the array of className rows

void
_buildNestedSetRows($className, $data)

Build the rows for nested set models

_getImportedObject(string $rowKey, Doctrine_Record $record, string $relationName, string $referringRowKey)

Get the unsaved object for a specified row key and validate that it is the valid object class for the passed record and relation name

void
_processRow(string $rowKey, string $row)

Process a row and make all the appropriate relations between the imported data

boolean
_hasNaturalNestedSetFormat($className, array $data)

NestedSet fixtures may come in a 'natural' format with nested children listed under a 'children' key or in a raw, non-nested format with lft/rgt values.

void
_loadData(array $array)

Perform the loading of the data from the passed array

void
_loadNestedSetData(string $model, string $nestedSetData, string $parent = null)

Load nested set data for models with nested set enabled

string
_getRowKeyPrefix(Doctrine_Table $table)

Returns the prefix to use when indexing an object from the supplied table.

Details

void setFormat(string $format)

setFormat

Set the current format we are working with

Parameters

string $format

Return Value

void

void getFormat()

getFormat

Get the current format we are working with

Return Value

void

void getFormats()

getFormats

Get array of available formats

Return Value

void

void setDirectory($directory)

setDirectory

Set the array/string of directories or yml file paths

Parameters

$directory

Return Value

void

void getDirectory()

getDirectory

Get directory for dumping/loading data from and to

Return Value

void

void setModels(string $models)

setModels

Set the array of specified models to work with

Parameters

string $models

Return Value

void

void getModels()

getModels

Get the array of specified models to work with

Return Value

void

bool exportIndividualFiles($bool = null)

_exportIndividualFiles

Set/Get whether or not to export individual files

Parameters

$bool

Return Value

bool $_exportIndividualFiles

void exportData(string $directory, string $format = 'yml', string $models = array(), string $_exportIndividualFiles = false)

exportData

Interface for exporting data to fixtures files from Doctrine models

Parameters

string $directory
string $format
string $models
string $_exportIndividualFiles

Return Value

void

void importData($directory, $format = 'yml', $models = array(), $append = false)

importData

Interface for importing data from fixture files to Doctrine models

Parameters

$directory
$format
$models
$append

Return Value

void

void isRelation(Doctrine_Record $record, $fieldName)

isRelation

Check if a fieldName on a Doctrine_Record is a relation, if it is we return that relationData

Parameters

Doctrine_Record $record
$fieldName

Return Value

void

void purge(string $models = null)

purge

Purge all data for loaded models or for the passed array of Doctrine_Records

Parameters

string $models

Return Value

void

void __construct(string $directory = null)

Optionally pass the directory/path to the yaml for importing

Parameters

string $directory

Return Value

void

array doParsing()

Do the parsing of the yaml files and return the final parsed array

Return Value

array $array

void doImport($append = false)

Do the importing of the data parsed from the fixtures

Parameters

$append

Return Value

void

protected void _buildRows($className, $data)

Recursively loop over all data fixtures and build the array of className rows

Parameters

$className
$data

Return Value

void

protected void _buildNestedSetRows($className, $data)

Build the rows for nested set models

Parameters

$className
$data

Return Value

void

protected Doctrine_Record _getImportedObject(string $rowKey, Doctrine_Record $record, string $relationName, string $referringRowKey)

Get the unsaved object for a specified row key and validate that it is the valid object class for the passed record and relation name

Parameters

string $rowKey
Doctrine_Record $record
string $relationName
string $referringRowKey

Return Value

Doctrine_Record

Exceptions

Doctrine_Data_Exception

protected void _processRow(string $rowKey, string $row)

Process a row and make all the appropriate relations between the imported data

Parameters

string $rowKey
string $row

Return Value

void

protected boolean _hasNaturalNestedSetFormat($className, array $data)

NestedSet fixtures may come in a 'natural' format with nested children listed under a 'children' key or in a raw, non-nested format with lft/rgt values.

This method returns true if the given $data is a nested set in 'natural' form.

Parameters

$className
array $data

Return Value

boolean

protected void _loadData(array $array)

Perform the loading of the data from the passed array

Parameters

array $array

Return Value

void

protected void _loadNestedSetData(string $model, string $nestedSetData, string $parent = null)

Load nested set data for models with nested set enabled

Parameters

string $model
string $nestedSetData
string $parent

Return Value

void

protected string _getRowKeyPrefix(Doctrine_Table $table)

Returns the prefix to use when indexing an object from the supplied table.

Parameters

Doctrine_Table $table

Return Value

string