Skip to content

Commit

Permalink
FIX: Ensure that silverstripe/framework 2.* is installed to
Browse files Browse the repository at this point in the history
sapphire, not framework, as the package requires.

Closes composerGH-70
  • Loading branch information
Sam Minnee authored and shama committed Apr 22, 2013
1 parent d6d0914 commit 6c23b07
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/Composer/Installers/SilverStripeInstaller.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
<?php
namespace Composer\Installers;

use Composer\Package\PackageInterface;

class SilverStripeInstaller extends BaseInstaller
{
protected $locations = array(
'module' => '{$name}/',
'theme' => 'themes/{$name}/',
);

/**
* Return the install path based on package type.
*
* Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework
* must be installed to 'sapphire' and not 'framework' if the version is <3.0.0
*
* @param PackageInterface $package
* @param string $frameworkType
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
{
if($package->getName() == 'silverstripe/framework' && version_compare($package->getVersion(), '3.0.0') < 0) {
return $this->templatePath($this->locations['module'], array('name' => 'sapphire'));
} else {
return parent::getInstallPath($package, $frameworkType);
}

}
}
6 changes: 4 additions & 2 deletions tests/Composer/Installers/Test/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public function dataForTestSupport()
*
* @dataProvider dataForTestInstallPath
*/
public function testInstallPath($type, $path, $name)
public function testInstallPath($type, $path, $name, $version = '1.0.0')
{
$installer = new Installer($this->io, $this->composer);
$package = new Package($name, '1.0.0', '1.0.0');
$package = new Package($name, $version, $version);

$package->setType($type);
$result = $installer->getInstallPath($package);
Expand Down Expand Up @@ -157,6 +157,8 @@ public function dataForTestInstallPath()
array('phpbb-language', 'language/foo/', 'test/foo'),
array('ppi-module', 'modules/foo/', 'test/foo'),
array('silverstripe-module', 'my_module/', 'shama/my_module'),
array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),
array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),
array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
Expand Down

0 comments on commit 6c23b07

Please sign in to comment.