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
31d9cbd9
Commit
31d9cbd9
authored
May 22, 2013
by
Tobias Munk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added run method to execute yii commands
parent
b6283cc9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
InstallHandler.php
extensions/composer/yii/composer/InstallHandler.php
+33
-0
No files found.
extensions/composer/yii/composer/InstallHandler.php
View file @
31d9cbd9
...
@@ -9,10 +9,16 @@ namespace yii\composer;
...
@@ -9,10 +9,16 @@ namespace yii\composer;
use
Composer\Script\CommandEvent
;
use
Composer\Script\CommandEvent
;
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.
* InstallHandler is called by Composer after it installs/updates the current package.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Tobias Munk <schmunk@usrbin.de>
* @since 2.0
* @since 2.0
*/
*/
class
InstallHandler
class
InstallHandler
...
@@ -50,4 +56,31 @@ class InstallHandler
...
@@ -50,4 +56,31 @@ class InstallHandler
}
}
}
}
}
}
/**
* Executes a yii command.
* @param CommandEvent $event
*/
public
static
function
run
(
$event
)
{
$options
=
array_merge
(
array
(
'run'
=>
array
(),
),
$event
->
getComposer
()
->
getPackage
()
->
getExtra
());
$appPath
=
realpath
(
__DIR__
.
'/../../../../..'
);
require
(
$appPath
.
'/vendor/yiisoft/yii2/yii/Yii.php'
);
require
(
$appPath
.
'/vendor/autoload.php'
);
$config
=
require
(
$appPath
.
'/config/console.php'
);
foreach
((
array
)
$options
[
'run'
]
as
$params
){
$command
=
$params
[
0
];
unset
(
$params
[
0
]);
$params
=
array
();
// TODO: add params to array
echo
"Running command:
{
$command
}
\n
"
;
$application
=
new
\yii\console\Application
(
$config
);
$application
->
runAction
(
$command
,
$params
);
}
}
}
}
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