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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
d047f710
Commit
d047f710
authored
Oct 22, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaned up Installer.
parent
0c517ce9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
38 deletions
+3
-38
Installer.php
extensions/composer/yii/composer/Installer.php
+3
-38
No files found.
extensions/composer/yii/composer/Installer.php
View file @
d047f710
...
...
@@ -11,8 +11,6 @@ use Composer\Package\PackageInterface;
use
Composer\Installer\LibraryInstaller
;
use
Composer\Repository\InstalledRepositoryInterface
;
use
Composer\Script\CommandEvent
;
use
yii\console\Application
;
use
yii\console\Exception
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
...
...
@@ -20,11 +18,9 @@ use yii\console\Exception;
*/
class
Installer
extends
LibraryInstaller
{
const
EXTRA_BOOTSTRAP
=
'bootstrap'
;
const
EXTRA_WRITABLE
=
'writable'
;
const
EXTRA_EXECUTABLE
=
'executable'
;
const
EXTRA_CONFIG
=
'yii-config'
;
const
EXTRA_COMMANDS
=
'yii-commands'
;
const
EXTRA_BOOTSTRAP
=
'bootstrap'
;
/**
* @inheritdoc
...
...
@@ -101,10 +97,10 @@ class Installer extends LibraryInstaller
/**
* Sets the correct permission
s of files and directories
.
* Sets the correct permission
for the files and directories listed in the extra section
.
* @param CommandEvent $event
*/
public
static
function
setPermission
s
(
$event
)
public
static
function
setPermission
(
$event
)
{
$options
=
array_merge
([
self
::
EXTRA_WRITABLE
=>
[],
...
...
@@ -133,35 +129,4 @@ class Installer extends LibraryInstaller
}
}
}
/**
* Executes a yii command.
* @param CommandEvent $event
*/
public
static
function
run
(
$event
)
{
$options
=
array_merge
([
self
::
EXTRA_COMMANDS
=>
[],
],
$event
->
getComposer
()
->
getPackage
()
->
getExtra
());
if
(
!
isset
(
$options
[
self
::
EXTRA_CONFIG
]))
{
throw
new
Exception
(
'Please specify the "'
.
self
::
EXTRA_CONFIG
.
'" parameter in composer.json.'
);
}
$configFile
=
getcwd
()
.
'/'
.
$options
[
self
::
EXTRA_CONFIG
];
if
(
!
is_file
(
$configFile
))
{
throw
new
Exception
(
"Config file does not exist:
$configFile
"
);
}
require_once
(
__DIR__
.
'/../../../yii2/yii/Yii.php'
);
$application
=
new
Application
(
require
(
$configFile
));
$request
=
$application
->
getRequest
();
foreach
((
array
)
$options
[
self
::
EXTRA_COMMANDS
]
as
$command
)
{
$params
=
str_getcsv
(
$command
,
' '
);
// see http://stackoverflow.com/a/6609509/291573
$request
->
setParams
(
$params
);
list
(
$route
,
$params
)
=
$request
->
resolve
();
echo
"Running command: yii
{
$command
}
\n
"
;
$application
->
runAction
(
$route
,
$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