123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?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 [];
- }
- }
|