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
e1593847
Commit
e1593847
authored
Jul 18, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored console commands.
parent
0067e8c9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
22 deletions
+17
-22
Application.php
framework/yii/base/Application.php
+4
-0
Controller.php
framework/yii/console/Controller.php
+7
-9
Request.php
framework/yii/console/Request.php
+2
-4
MessageController.php
framework/yii/console/controllers/MessageController.php
+1
-1
AssetControllerTest.php
...nit/framework/console/controllers/AssetControllerTest.php
+1
-4
MessageControllerTest.php
...t/framework/console/controllers/MessageControllerTest.php
+2
-4
No files found.
framework/yii/base/Application.php
View file @
e1593847
...
...
@@ -8,6 +8,7 @@
namespace
yii\base
;
use
Yii
;
use
yii\helpers\Console
;
use
yii\web\HttpException
;
/**
...
...
@@ -510,6 +511,9 @@ abstract class Application extends Module
{
if
(
$exception
instanceof
Exception
&&
(
$exception
instanceof
UserException
||
!
YII_DEBUG
))
{
$message
=
$exception
->
getName
()
.
': '
.
$exception
->
getMessage
();
if
(
Yii
::
$app
->
controller
instanceof
\yii\console\Controller
)
{
$message
=
Yii
::
$app
->
controller
->
ansiFormat
(
$message
,
Console
::
FG_RED
);
}
}
else
{
$message
=
YII_DEBUG
?
(
string
)
$exception
:
'Error: '
.
$exception
->
getMessage
();
}
...
...
framework/yii/console/Controller.php
View file @
e1593847
...
...
@@ -89,24 +89,22 @@ class Controller extends \yii\base\Controller
*/
public
function
bindActionParams
(
$action
,
$params
)
{
$args
=
array
();
if
(
!
empty
(
$params
))
{
$options
=
$this
->
globalOptions
();
foreach
(
$params
as
$name
=>
$value
)
{
if
(
in_array
(
$name
,
$options
,
true
))
{
$this
->
$name
=
$value
;
unset
(
$params
[
$name
]);
}
elseif
(
is_int
(
$name
))
{
$args
[]
=
$value
;
}
else
{
throw
new
Exception
(
Yii
::
t
(
'yii'
,
'Unknown option: --{name}'
,
array
(
'{name}'
=>
$name
,
)));
}
}
}
$args
=
isset
(
$params
[
Request
::
ANONYMOUS_PARAMS
])
?
$params
[
Request
::
ANONYMOUS_PARAMS
]
:
array
();
unset
(
$params
[
Request
::
ANONYMOUS_PARAMS
]);
if
(
!
empty
(
$params
))
{
throw
new
Exception
(
Yii
::
t
(
'yii'
,
'Unknown options: {params}'
,
array
(
'{params}'
=>
implode
(
', '
,
array_keys
(
$params
)),
)));
}
if
(
$action
instanceof
InlineAction
)
{
$method
=
new
\ReflectionMethod
(
$this
,
$action
->
actionMethod
);
}
else
{
...
...
framework/yii/console/Request.php
View file @
e1593847
...
...
@@ -13,8 +13,6 @@ namespace yii\console;
*/
class
Request
extends
\yii\base\Request
{
const
ANONYMOUS_PARAMS
=
'-args'
;
private
$_params
;
/**
...
...
@@ -57,13 +55,13 @@ class Request extends \yii\base\Request
$route
=
''
;
}
$params
=
array
(
self
::
ANONYMOUS_PARAMS
=>
array
()
);
$params
=
array
();
foreach
(
$rawParams
as
$param
)
{
if
(
preg_match
(
'/^--(\w+)(=(.*))?$/'
,
$param
,
$matches
))
{
$name
=
$matches
[
1
];
$params
[
$name
]
=
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
true
;
}
else
{
$params
[
self
::
ANONYMOUS_PARAMS
][
]
=
$param
;
$params
[]
=
$param
;
}
}
...
...
framework/yii/console/controllers/MessageController.php
View file @
e1593847
...
...
@@ -71,7 +71,7 @@ class MessageController extends Controller
public
function
actionExtract
(
$configFile
)
{
if
(
!
is_file
(
$configFile
))
{
throw
new
Exception
(
"
the configuration file
{
$configFile
}
does not exist.
"
);
throw
new
Exception
(
"
The configuration file does not exist:
$configFile
"
);
}
$config
=
array_merge
(
array
(
...
...
tests/unit/framework/console/controllers/AssetControllerTest.php
View file @
e1593847
...
...
@@ -79,10 +79,7 @@ class AssetControllerTest extends TestCase
$controller
=
$this
->
createAssetController
();
ob_start
();
ob_implicit_flush
(
false
);
$params
=
array
(
\yii\console\Request
::
ANONYMOUS_PARAMS
=>
$args
);
$controller
->
run
(
$actionId
,
$params
);
$controller
->
run
(
$actionId
,
$args
);
return
ob_get_clean
();
}
...
...
tests/unit/framework/console/controllers/MessageControllerTest.php
View file @
e1593847
...
...
@@ -15,6 +15,7 @@ class MessageControllerTest extends TestCase
public
function
setUp
()
{
$this
->
mockApplication
();
$this
->
sourcePath
=
Yii
::
getAlias
(
'@yiiunit/runtime/test_source'
);
$this
->
createDir
(
$this
->
sourcePath
);
if
(
!
file_exists
(
$this
->
sourcePath
))
{
...
...
@@ -100,10 +101,7 @@ class MessageControllerTest extends TestCase
$controller
=
$this
->
createMessageController
();
ob_start
();
ob_implicit_flush
(
false
);
$params
=
array
(
\yii\console\Request
::
ANONYMOUS_PARAMS
=>
$args
);
$controller
->
run
(
$actionId
,
$params
);
$controller
->
run
(
$actionId
,
$args
);
return
ob_get_clean
();
}
...
...
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