1 | <?php |
||
32 | class ActiveFixture extends BaseActiveFixture |
||
33 | { |
||
34 | /** |
||
35 | * @var string the name of the database table that this fixture is about. If this property is not set, |
||
36 | * the table name will be determined via [[modelClass]]. |
||
37 | * @see modelClass |
||
38 | */ |
||
39 | public $tableName; |
||
40 | /** |
||
41 | * @var string|boolean the file path or path alias of the data file that contains the fixture data |
||
42 | * to be returned by [[getData()]]. If this is not set, it will default to `FixturePath/data/TableName.php`, |
||
43 | * where `FixturePath` stands for the directory containing this fixture class, and `TableName` stands for the |
||
44 | * name of the table associated with this fixture. You can set this property to be false to prevent loading any data. |
||
45 | */ |
||
46 | public $dataFile; |
||
47 | |||
48 | /** |
||
49 | * @var TableSchema the table schema for the table associated with this fixture |
||
50 | */ |
||
51 | private $_table; |
||
52 | |||
53 | |||
54 | /** |
||
55 | * @inheritdoc |
||
56 | */ |
||
57 | 6 | public function init() |
|
64 | |||
65 | /** |
||
66 | * Loads the fixture. |
||
67 | * |
||
68 | * The default implementation will first clean up the table by calling [[resetTable()]]. |
||
69 | * It will then populate the table with the data returned by [[getData()]]. |
||
70 | * |
||
71 | * If you override this method, you should consider calling the parent implementation |
||
72 | * so that the data returned by [[getData()]] can be populated into the table. |
||
73 | */ |
||
74 | 6 | public function load() |
|
84 | |||
85 | /** |
||
86 | * Returns the fixture data. |
||
87 | * |
||
88 | * The default implementation will try to return the fixture data by including the external file specified by [[dataFile]]. |
||
89 | * The file should return an array of data rows (column name => column value), each corresponding to a row in the table. |
||
90 | * |
||
91 | * If the data file does not exist, an empty array will be returned. |
||
92 | * |
||
93 | * @return array the data rows to be inserted into the database table. |
||
94 | */ |
||
95 | 6 | protected function getData() |
|
106 | |||
107 | /** |
||
108 | * Removes all existing data from the specified table and resets sequence number to 1 (if any). |
||
109 | * This method is called before populating fixture data into the table associated with this fixture. |
||
110 | */ |
||
111 | 6 | protected function resetTable() |
|
119 | |||
120 | /** |
||
121 | * @return TableSchema the schema information of the database table associated with this fixture. |
||
122 | * @throws \yii\base\InvalidConfigException if the table does not exist |
||
123 | */ |
||
124 | 6 | public function getTableSchema() |
|
145 | } |
||
146 |