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
7d42fc41
Commit
7d42fc41
authored
Jan 03, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code style fixes
parent
08ee8b18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
15 deletions
+12
-15
basics.md
docs/guide/basics.md
+1
-1
FixtureController.php
framework/yii/console/controllers/FixtureController.php
+11
-14
No files found.
docs/guide/basics.md
View file @
7d42fc41
...
...
@@ -90,7 +90,7 @@ For example, if standard alias `@app` refers to `/var/www/example.com/` then `\a
Custom alias may be added using the following code:
```
php
Yii
::
setAlias
(
'shared'
,
realpath
(
'~/src/shared'
));
Yii
::
setAlias
(
'
@
shared'
,
realpath
(
'~/src/shared'
));
```
Additional autoloaders may be registered using standard PHP
`spl_autoload_register`
.
...
...
framework/yii/console/controllers/FixtureController.php
View file @
7d42fc41
...
...
@@ -52,26 +52,24 @@ use yii\helpers\Console;
*/
class
FixtureController
extends
Controller
{
use
DbTestTrait
;
/**
* @var string controller default action ID.
*/
public
$defaultAction
=
'apply'
;
/**
* Alias to the path, where all fixtures are stored.
* @var string
*/
public
$fixturePath
=
'@tests/unit/fixtures'
;
/**
* Id of the database connection component of the application.
* @var string
*/
public
$db
=
'db'
;
/**
* Returns the names of the global options for this command.
* @return array the names of the global options for this command.
...
...
@@ -102,13 +100,13 @@ class FixtureController extends Controller
/**
* Apply given fixture to the table. Fixture name can be the same as the table name or
* you can specify table name as a second parameter.
* @param string $fixture
* @param array $fixtures
* @throws \yii\console\Exception
*/
public
function
actionApply
(
array
$fixtures
)
{
if
(
$this
->
getFixtureManager
()
==
null
)
{
throw
new
Exception
(
'Fixture manager is not configured properly. '
throw
new
Exception
(
'Fixture manager is not configured properly. '
.
'Please refer to official documentation for this purposes.'
);
}
...
...
@@ -124,7 +122,7 @@ class FixtureController extends Controller
/**
* Truncate given table and clear all fixtures from it.
* @param string $tables
* @param
array|
string $tables
*/
public
function
actionClear
(
array
$tables
)
{
...
...
@@ -161,7 +159,7 @@ class FixtureController extends Controller
{
$db
=
Yii
::
$app
->
getComponent
(
$this
->
db
);
if
(
$db
==
null
)
{
if
(
$db
==
=
null
)
{
throw
new
Exception
(
"There is no database connection component with id
\"
{
$this
->
db
}
\"
."
);
}
...
...
@@ -174,8 +172,8 @@ class FixtureController extends Controller
*/
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
);
$this
->
stdout
(
"Fixtures were successfully loaded from path:
\n
"
,
Console
::
FG_YELLOW
);
$this
->
stdout
(
Yii
::
getAlias
(
$this
->
fixturePath
)
.
"
\n\n
"
,
Console
::
FG_GREEN
);
$this
->
outputList
(
$fixtures
);
}
...
...
@@ -187,7 +185,7 @@ class FixtureController extends Controller
private
function
confirmApply
(
$fixtures
)
{
$this
->
stdout
(
"Fixtures will be loaded from path:
\n
"
,
Console
::
FG_YELLOW
);
$this
->
stdout
(
realpath
(
Yii
::
getAlias
(
$this
->
fixturePath
)
)
.
"
\n\n
"
,
Console
::
FG_GREEN
);
$this
->
stdout
(
Yii
::
getAlias
(
$this
->
fixturePath
)
.
"
\n\n
"
,
Console
::
FG_GREEN
);
$this
->
outputList
(
$fixtures
);
return
$this
->
confirm
(
'Load to database above fixtures?'
);
}
...
...
@@ -199,7 +197,7 @@ class FixtureController extends Controller
*/
private
function
confirmClear
(
$tables
)
{
$this
->
stdout
(
"Tables below will be cleared:
\n\n
"
,
Console
::
FG_YELLOW
);
$this
->
stdout
(
"Tables below will be cleared:
\n\n
"
,
Console
::
FG_YELLOW
);
$this
->
outputList
(
$tables
);
return
$this
->
confirm
(
'Clear tables?'
);
}
...
...
@@ -211,8 +209,7 @@ class FixtureController extends Controller
private
function
outputList
(
$data
)
{
foreach
(
$data
as
$index
=>
$item
)
{
$this
->
stdout
(
$index
+
1
.
". "
.
$item
.
"
\n
"
,
Console
::
FG_GREEN
);
$this
->
stdout
(
(
$index
+
1
)
.
".
{
$item
}
\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