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
999b4255
Commit
999b4255
authored
Nov 22, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow installing yii2-dev and get the Yii.php file in the same place
parent
898bbf33
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
Installer.php
extensions/composer/Installer.php
+52
-0
No files found.
extensions/composer/Installer.php
View file @
999b4255
...
...
@@ -38,8 +38,14 @@ class Installer extends LibraryInstaller
*/
public
function
install
(
InstalledRepositoryInterface
$repo
,
PackageInterface
$package
)
{
// install the package the normal composer way
parent
::
install
(
$repo
,
$package
);
// add the package to yiisoft/extensions.php
$this
->
addPackage
(
$package
);
// ensure the yii2-dev package also provides Yii.php in the same place as yii2 does
if
(
$package
->
getName
()
==
'yiisoft/yii2-dev'
)
{
$this
->
linkYiiBaseFiles
();
}
}
/**
...
...
@@ -50,6 +56,10 @@ class Installer extends LibraryInstaller
parent
::
update
(
$repo
,
$initial
,
$target
);
$this
->
removePackage
(
$initial
);
$this
->
addPackage
(
$target
);
// ensure the yii2-dev package also provides Yii.php in the same place as yii2 does
if
(
$package
->
getName
()
==
'yiisoft/yii2-dev'
)
{
$this
->
linkYiiBaseFiles
();
}
}
/**
...
...
@@ -57,8 +67,14 @@ class Installer extends LibraryInstaller
*/
public
function
uninstall
(
InstalledRepositoryInterface
$repo
,
PackageInterface
$package
)
{
// uninstall the package the normal composer way
parent
::
uninstall
(
$repo
,
$package
);
// remove the package from yiisoft/extensions.php
$this
->
removePackage
(
$package
);
// remove links for Yii.php
if
(
$package
->
getName
()
==
'yiisoft/yii2-dev'
)
{
$this
->
removeYiiBaseFiles
();
}
}
protected
function
addPackage
(
PackageInterface
$package
)
...
...
@@ -145,6 +161,42 @@ class Installer extends LibraryInstaller
file_put_contents
(
$file
,
"<?php
\n\n\$
vendorDir = dirname(__DIR__);
\n\n
return
$array
;
\n
"
);
}
protected
function
linkYiiBaseFiles
()
{
$yiiDir
=
$this
->
vendorDir
.
'/yiisoft/yii2/yii'
;
if
(
!
file_exists
(
$yiiDir
))
{
mkdir
(
$yiiDir
,
0777
,
true
);
}
foreach
([
'Yii.php'
,
'YiiBase.php'
,
'classes.php'
]
as
$file
)
{
file_put_contents
(
$yiiDir
.
'/'
.
$file
,
<<<EOF
<?php
/**
* This is a link provided by the yiisoft/yii2-dev package via yii2-composer plugin.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
return require(__DIR__ . '/../../yii2-dev/framework/yii/$file');
EOF
);
}
}
protected
function
removeYiiBaseFiles
()
{
$yiiDir
=
$this
->
vendorDir
.
'/yiisoft/yii2/yii'
;
foreach
([
'Yii.php'
,
'YiiBase.php'
,
'classes.php'
]
as
$file
)
{
if
(
file_exists
(
$yiiDir
.
'/'
.
$file
))
{
unlink
(
$yiiDir
.
'/'
.
$file
);
}
}
if
(
file_exists
(
$yiiDir
))
{
rmdir
(
$yiiDir
);
}
}
/**
* Sets the correct permission for the files and directories listed in the extra section.
...
...
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