Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
ccfb7638
Commit
ccfb7638
authored
Jan 04, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added to the basic app, fixed config, added to core commands.
parent
6291d0c2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
2 deletions
+38
-2
console.php
apps/basic/config/console.php
+14
-0
.gitkeep
apps/basic/tests/unit/fixtures/.gitkeep
+0
-0
.gitkeep
apps/basic/tests/unit/templates/fixtures/.gitkeep
+0
-0
Application.php
framework/yii/console/Application.php
+1
-0
FixtureController.php
framework/yii/console/controllers/FixtureController.php
+23
-2
No files found.
apps/basic/config/console.php
View file @
ccfb7638
<?php
<?php
Yii
::
setAlias
(
'tests'
,
__DIR__
.
'/../tests'
);
$params
=
require
(
__DIR__
.
'/params.php'
);
$params
=
require
(
__DIR__
.
'/params.php'
);
return
[
return
[
'id'
=>
'basic-console'
,
'id'
=>
'basic-console'
,
...
@@ -19,6 +22,17 @@ return [
...
@@ -19,6 +22,17 @@ return [
],
],
],
],
],
],
'db'
=>
[
'class'
=>
'yii\db\Connection'
,
'dsn'
=>
'mysql:host=localhost;dbname=yii2basic'
,
'username'
=>
'root'
,
'password'
=>
''
,
'charset'
=>
'utf8'
,
],
'fixture'
=>
[
'class'
=>
'yii\test\DbFixtureManager'
,
'basePath'
=>
'@tests/unit/fixtures'
,
],
],
],
'params'
=>
$params
,
'params'
=>
$params
,
];
];
apps/basic/tests/unit/fixtures/.gitkeep
0 → 100644
View file @
ccfb7638
apps/basic/tests/unit/templates/fixtures/.gitkeep
0 → 100644
View file @
ccfb7638
framework/yii/console/Application.php
View file @
ccfb7638
...
@@ -146,6 +146,7 @@ class Application extends \yii\base\Application
...
@@ -146,6 +146,7 @@ class Application extends \yii\base\Application
'migrate'
=>
'yii\console\controllers\MigrateController'
,
'migrate'
=>
'yii\console\controllers\MigrateController'
,
'cache'
=>
'yii\console\controllers\CacheController'
,
'cache'
=>
'yii\console\controllers\CacheController'
,
'asset'
=>
'yii\console\controllers\AssetController'
,
'asset'
=>
'yii\console\controllers\AssetController'
,
'fixture'
=>
'yii\console\controllers\FixtureController'
,
];
];
}
}
...
...
framework/yii/console/controllers/FixtureController.php
View file @
ccfb7638
...
@@ -103,11 +103,18 @@ class FixtureController extends Controller
...
@@ -103,11 +103,18 @@ class FixtureController extends Controller
* you can specify table name as a second parameter.
* you can specify table name as a second parameter.
* @param string $fixture
* @param string $fixture
*/
*/
public
function
actionApply
(
$fixture
)
public
function
actionApply
(
array
$fixture
)
{
{
if
(
$this
->
getFixtureManager
()
==
null
)
{
throw
new
Exception
(
'Fixture manager is not configured properly. '
.
'Please refer to official documentation for this purposes.'
);
}
$this
->
getFixtureManager
()
->
basePath
=
$this
->
fixturePath
;
$this
->
getFixtureManager
()
->
basePath
=
$this
->
fixturePath
;
$this
->
getFixtureManager
()
->
db
=
$this
->
db
;
$this
->
getFixtureManager
()
->
db
=
$this
->
db
;
$this
->
loadFixtures
([
$fixture
]);
$this
->
loadFixtures
(
$fixture
);
$this
->
notifySuccess
(
$fixture
);
}
}
/**
/**
...
@@ -150,4 +157,18 @@ class FixtureController extends Controller
...
@@ -150,4 +157,18 @@ class FixtureController extends Controller
return
$db
;
return
$db
;
}
}
/**
* Notifies user that fixtures were successfully loaded.
* @param array $fixtures
*/
private
function
notifySuccess
(
$fixtures
)
{
$this
->
stdout
(
"Fixtures were successfully loaded from path:
\n
"
,
Console
::
FG_YELLOW
);
$this
->
stdout
(
realpath
(
Yii
::
getAlias
(
$this
->
fixturePath
))
.
"
\n\n
"
,
Console
::
FG_GREEN
);
foreach
(
$fixtures
as
$index
=>
$fixture
)
{
$this
->
stdout
(
$index
+
1
.
". "
.
$fixture
.
"
\n
"
,
Console
::
FG_GREEN
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment