From 999b42555dd6c596b8517db1b3b8dc06bb9a8565 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Fri, 22 Nov 2013 22:48:37 +0100 Subject: [PATCH] allow installing yii2-dev and get the Yii.php file in the same place --- extensions/composer/Installer.php | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/extensions/composer/Installer.php b/extensions/composer/Installer.php index fbbe329..9a63106 100644 --- a/extensions/composer/Installer.php +++ b/extensions/composer/Installer.php @@ -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, "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, <<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.