Browse Source

Enhanced FixtureController::getFixtureRelativeName()

Updated CHANGELOG
tags/2.0.12
SilverFire - Dmitry Naumenko 7 years ago
parent
commit
f7c9e6b852
No known key found for this signature in database
GPG Key ID: 39DD917A92B270A
  1. 1
      framework/CHANGELOG.md
  2. 25
      framework/console/controllers/FixtureController.php

1
framework/CHANGELOG.md

@ -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)

25
framework/console/controllers/FixtureController.php

@ -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');
}
/**

Loading…
Cancel
Save