PHP Class yii\mongodb\ActiveFixture
Either [[modelClass]] or [[collectionName]] 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::resetCollection to remove any existing data in the collection.
It will then populate the table 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()]].
Show file
Open project: yiisoft/yii2-mongodb
Public Properties
Property |
Type |
Description |
|
$collectionName |
|
the collection name that this fixture is about. If this property is not set,
the collection name will be determined via [[modelClass]]. |
|
$db |
|
the DB connection object or the application component ID of the DB connection. |
|
Public Methods
Method |
Description |
|
init ( ) |
|
|
load ( ) |
Loads the fixture data. |
|
Protected Methods
Method Details
getCollection()
protected method
Returns collection used by this fixture.
protected getCollection ( ) : Collection |
return |
Collection |
related collection. |
getCollectionName()
protected method
Returns collection name used by this fixture.
getData()
protected method
This method is called by [[loadData()]] to get the needed fixture data.
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 collection.
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 collection. |
The default implementation will first reset the MongoDB collection and then populate it with the data
returned by
ActiveFixture::getData.
resetCollection()
protected method
This method is called before populating fixture data into the collection associated with this fixture.
Property Details
$collectionName public property
the collection name that this fixture is about. If this property is not set,
the collection name will be determined via [[modelClass]].
the DB connection object or the application component ID of the DB connection.