PHP Class yii\sphinx\ActiveFixture

Either [[modelClass]] or [[indexName]] must be set. You should also provide fixture data in the file specified by [[dataFile]] or overriding ActiveFixture::getData if you want to use code to generate the fixture data. When the fixture is being loaded, it will first call ActiveFixture::resetIndex to remove any existing data in the index. It will then populate the index with the data returned by ActiveFixture::getData. After the fixture is loaded, you can access the loaded data via the [[data]] property. If you set [[modelClass]], you will also be able to retrieve an instance of [[modelClass]] with the populated data via [[getModel()]]. Note: only runtime indexes are supported.
Since: 2.0.4
Author: Paul Klimov ([email protected])
Inheritance: extends yii\test\BaseActiveFixture
Show file Open project: yiisoft/yii2-sphinx

Public Properties

Property Type Description
$dataFile the file path or path alias of the data file that contains the fixture data to be returned by ActiveFixture::getData. If this is not set, it will default to FixturePath/data/IndexName.php, where FixturePath stands for the directory containing this fixture class, and IndexName stands for the name of the index associated with this fixture. You can set this property to be false to prevent loading any data.
$db the Sphinx connection object or the application component ID of the Sphinx connection or a configuration array for creating the object.
$indexName the name of the Sphinx index that this fixture is about. If this property is not set, the index name will be determined via [[modelClass]].

Public Methods

Method Description
getIndexSchema ( ) : IndexSchema
init ( )
load ( ) Loads the fixture.

Protected Methods

Method Description
getData ( ) : array Returns the fixture data.
resetIndex ( ) Truncates the specified index removing all existing data from it.

Method Details

getData() protected method

The default implementation will try to return the fixture data by including the external file specified by [[dataFile]]. The file should return an array of data rows (column name => column value), each corresponding to a row in the index. If the data file does not exist, an empty array will be returned.
protected getData ( ) : array
return array the data rows to be inserted into the index.

getIndexSchema() public method

public getIndexSchema ( ) : IndexSchema
return IndexSchema the schema information of the database table associated with this fixture.

init() public method

public init ( )

load() public method

The default implementation will first clean up the table by calling ActiveFixture::resetIndex. It will then populate the index with the data returned by ActiveFixture::getData. If you override this method, you should consider calling the parent implementation so that the data returned by ActiveFixture::getData can be populated into the index.
public load ( )

resetIndex() protected method

This method is called before populating fixture data into the index associated with this fixture.
protected resetIndex ( )

Property Details

$dataFile public property

the file path or path alias of the data file that contains the fixture data to be returned by ActiveFixture::getData. If this is not set, it will default to FixturePath/data/IndexName.php, where FixturePath stands for the directory containing this fixture class, and IndexName stands for the name of the index associated with this fixture. You can set this property to be false to prevent loading any data.
public $dataFile

$db public property

the Sphinx connection object or the application component ID of the Sphinx connection or a configuration array for creating the object.
public $db

$indexName public property

the name of the Sphinx index that this fixture is about. If this property is not set, the index name will be determined via [[modelClass]].
See also: modelClass
public $indexName