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
ddfd1696
Commit
ddfd1696
authored
May 23, 2013
by
resurtm
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:yiisoft/yii2
parents
d67416ab
8f0b6467
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
HelloController.php
apps/bootstrap/commands/HelloController.php
+2
-1
InstallHandler.php
extensions/composer/yii/composer/InstallHandler.php
+44
-0
Application.php
framework/yii/web/Application.php
+8
-1
No files found.
apps/bootstrap/commands/HelloController.php
View file @
ddfd1696
...
...
@@ -24,6 +24,6 @@ class HelloController extends Controller
*/
public
function
actionIndex
(
$message
=
'hello world'
)
{
echo
$message
;
echo
$message
.
"
\n
"
;
}
}
\ No newline at end of file
extensions/composer/yii/composer/InstallHandler.php
View file @
ddfd1696
...
...
@@ -8,11 +8,18 @@
namespace
yii\composer
;
use
Composer\Script\CommandEvent
;
use
yii\console
;
defined
(
'YII_DEBUG'
)
or
define
(
'YII_DEBUG'
,
true
);
// fcgi doesn't have STDIN defined by default
defined
(
'STDIN'
)
or
define
(
'STDIN'
,
fopen
(
'php://stdin'
,
'r'
));
/**
* InstallHandler is called by Composer after it installs/updates the current package.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Tobias Munk <schmunk@usrbin.de>
* @since 2.0
*/
class
InstallHandler
...
...
@@ -50,4 +57,41 @@ class InstallHandler
}
}
}
/**
* Executes a yii command.
* @param CommandEvent $event
*/
public
static
function
run
(
$event
)
{
$options
=
array_merge
(
array
(
'run'
=>
array
(),
'config'
=>
null
,
),
$event
->
getComposer
()
->
getPackage
()
->
getExtra
());
// resolve and include config file
if
((
$options
[
'config'
]
===
null
))
{
throw
new
console\Exception
(
'Config file not specified in composer.json extra.config'
);
}
else
{
if
(
!
is_file
(
getcwd
()
.
'/'
.
$options
[
'config'
]))
{
throw
new
console\Exception
(
"Config file '
{
$options
[
'config'
]
}
' specified in composer.json extra.config not found"
);
}
else
{
$config
=
require
(
$options
[
'config'
]);
}
}
// prepare console application
require
(
__DIR__
.
'/../../../yii2/yii/Yii.php'
);
$application
=
new
\yii\console\Application
(
$config
);
$request
=
$application
->
getRequest
();
// run commands from extra.run
foreach
((
array
)
$options
[
'run'
]
as
$rawCommand
)
{
$opts
=
str_getcsv
(
$rawCommand
,
' '
);
// see http://stackoverflow.com/a/6609509/291573
$request
->
setParams
(
$opts
);
list
(
$command
,
$params
)
=
$request
->
resolve
();
echo
"Running command: yiic
{
$rawCommand
}
\n
"
;
$application
->
runAction
(
$command
,
$params
);
}
}
}
framework/yii/web/Application.php
View file @
ddfd1696
...
...
@@ -8,6 +8,8 @@
namespace
yii\web
;
use
Yii
;
use
yii\base\HttpException
;
use
yii\base\InvalidRouteException
;
/**
* Application is the base class for all application classes.
...
...
@@ -25,6 +27,7 @@ class Application extends \yii\base\Application
/**
* Processes the request.
* @return integer the exit status of the controller action (0 means normal, non-zero values mean abnormal)
* @throws HttpException if the request cannot be resolved.
*/
public
function
processRequest
()
{
...
...
@@ -32,7 +35,11 @@ class Application extends \yii\base\Application
Yii
::
setAlias
(
'@wwwroot'
,
dirname
(
$request
->
getScriptFile
()));
Yii
::
setAlias
(
'@www'
,
$request
->
getBaseUrl
());
list
(
$route
,
$params
)
=
$request
->
resolve
();
return
$this
->
runAction
(
$route
,
$params
);
try
{
return
$this
->
runAction
(
$route
,
$params
);
}
catch
(
InvalidRouteException
$e
)
{
throw
new
HttpException
(
404
,
$e
->
getMessage
(),
$e
->
getCode
(),
$e
);
}
}
private
$_homeUrl
;
...
...
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