1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace yii\test;
- use Yii;
- use yii\base\InvalidConfigException;
- trait FileFixtureTrait
- {
-
- public $dataDirectory;
-
- public $dataFile;
-
- protected function loadData($file, $throwException = true)
- {
- if ($file === null || $file === false) {
- return [];
- }
- if (basename($file) === $file && $this->dataDirectory !== null) {
- $file = $this->dataDirectory . '/' . $file;
- }
- $file = Yii::getAlias($file);
- if (is_file($file)) {
- return require $file;
- }
-
- if ($throwException) {
- throw new InvalidConfigException("Fixture data file does not exist: {$file}");
- }
- return [];
- }
- }
|