Enhanced FixtureController::getFixtureRelativeName()

Updated CHANGELOG
This commit is contained in:
SilverFire - Dmitry Naumenko
2017-05-30 21:23:27 +03:00
parent 51dd58cf34
commit f7c9e6b852
2 changed files with 11 additions and 15 deletions

View File

@ -29,6 +29,7 @@ Yii Framework 2 Change Log
- Bug #13513: Fixed RBAC migration to work correctly on Oracle DBMS (silverfire)
- Bug #13537: Fixed `yii\web\CacheSession::destroySession()` to work correctly when session is not written yet (silverfire, papalapa)
- Bug #13538: Fixed `yii\db\BaseActiveRecord::deleteAll()` changes method signature declared by `yii\db\ActiveRecordInterface::deleteAll()` (klimov-paul)
- Bug #13551: Fixed `FixtureController` to load fixtures from subdirectories (d1rtyf1ng3rs, silverfire)
- Bug #13571: Fix `yii\db\mssql\QueryBuilder::checkIntegrity` for all tables (boboldehampsink)
- Bug #13577: `yii\db\QueryBuilder::truncateTable` should work consistent over all databases (boboldehampsink)
- Bug #13582: PK column in `yii\db\pgsql\QueryBuilder::resetSequence()` was not quoted properly (boboldehampsink)

View File

@ -415,33 +415,28 @@ class FixtureController extends Controller
$foundFixtures = [];
foreach ($files as $fixture) {
$relativeName = $this->getFixtureRelativeName($fixture);
$foundFixtures[] = $relativeName;
$foundFixtures[] = $this->getFixtureRelativeName($fixture);
}
return $foundFixtures;
}
/**
* Calculates $fixture's name relatively to $templatePath.
* Basically, strips getFixturePath() and 'Fixture.php' prefix from fixture's full path
* Calculates fixture's name
* Basically, strips [[getFixturePath()]] and `Fixture.php' suffix from fixture's full path
* @see getFixturePath()
* @param string $fullFixturePath Full fixture path
* @return string Relative fixture name
*/
private function getFixtureRelativeName($fullFixturePath)
{
// $fixturesPath is normalized to unix format in getFixturesPath()
$fixturesPath = $this->getFixturePath();
// normalize $fixture to unix format
$fullFixturePath = str_replace("\\", "/", $fullFixturePath);
// strip $fixturesPath from $fixture's full path
$relativeName = str_replace($fixturesPath . "/", "", $fullFixturePath);
// get fixtures's directory
$relativeDir = dirname($relativeName) === '.' ? '' : dirname($relativeName) . '/';
// get fixture name relatively to $fixturesPath
$relativeName = $relativeDir . basename($fullFixturePath, 'Fixture.php');
return $relativeName;
$fixturesPath = FileHelper::normalizePath($this->getFixturePath());
$fullFixturePath = FileHelper::normalizePath($fullFixturePath);
$relativeName = substr($fullFixturePath, strlen($fixturesPath)+1);
$relativeDir = dirname($relativeName) === '.' ? '' : dirname($relativeName) . DIRECTORY_SEPARATOR;
return $relativeDir . basename($fullFixturePath, 'Fixture.php');
}
/**