Skip to content

Commit

Permalink
Added symlink for public folders
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi committed Aug 17, 2013
1 parent e6c9ccb commit 853998a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .buildpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path="vendor/seld/jsonlint/src"/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
<buildpathentry kind="src" path="vendor/justinrainbow/json-schema/src"/>
<buildpathentry kind="src" path="vendor/symfony/finder"/>
<buildpathentry kind="src" path="vendor/composer/composer/src"/>
<buildpathentry kind="src" path="src"/>
<buildpathentry kind="src" path="vendor/symfony/process"/>
<buildpathentry kind="src" path="vendor/symfony/console"/>
<buildpathentry excluding="composer/" kind="src" path="vendor/composer"/>
</buildpath>
1 change: 1 addition & 0 deletions .settings/org.eclipse.php.core.prefs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
eclipse.preferences.version=1
include_path=
phpVersion=php5.4
use_asp_tags_as_php=false
42 changes: 30 additions & 12 deletions src/keeko/composer/KeekoComposerInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class KeekoComposerInstaller extends \Composer\Installer\LibraryInstaller {
private $types = array (
'keeko-core',
'keeko-app',
'keeko-module'
'keeko-module',
'keeko-design'
);

public function __construct(IOInterface $io, Composer $composer, $type = 'library') {
Expand All @@ -32,19 +33,16 @@ public function getInstallPath(PackageInterface $package) {
if ($type === 'keeko-core') {
return 'core';
}

$folderMappings = array(
'keeko-app' => 'apps',
'keeko-modules' => 'modules'
);

return $folderMappings[$type].'/'.$package->getName();

return str_replace('keeko-', '', $type) .'/'.$package->getName();
}

/**
* {@inheritDoc}
*/
protected function installCode(PackageInterface $package) {
$installPath = $this->getInstallPath($package);
$publicDir = $this->filesystem->normalizePath(getcwd() . '/public/_keeko');
$local = $this->getLocalRepositoryPath();
$installed = false;

Expand All @@ -56,7 +54,7 @@ protected function installCode(PackageInterface $package) {

if (file_exists($path)) {
try {
$this->symlink($path, $this->getInstallPath($package));
$this->symlink($path, $installPath);
$installed = true;
} catch(IOException $e) {
$installed = false;
Expand All @@ -67,19 +65,39 @@ protected function installCode(PackageInterface $package) {
if (!$installed) {
parent::installCode($package);
}

// symlink package public folder to keeko's public folder
if ($package->getType() !== 'keeko-core') {
$packagePublicDir = $this->filesystem->normalizePath($installPath .'/public');

if (file_exists($packagePublicDir)) {
$target = $this->filesystem->normalizePath($publicDir . '/' . $package->getName());
$this->symlink($packagePublicDir, $target);
}
}
}

/**
* {@inheritDoc}
*/
protected function removeCode(PackageInterface $package) {
$path = $this->getInstallPath($package);
$publicDir = $this->filesystem->normalizePath(getcwd() . '/public/_keeko');
$installPath = $this->getInstallPath($package);

if (is_link($path)) {
unlink($path);
if (is_link($installPath)) {
unlink($installPath);
} else {
parent::removeCode($package);
}

// remove symlink package public folder to keeko's public folder
if ($package->getType() !== 'keeko-core') {
$target = $this->filesystem->normalizePath($publicDir . '/' . $package->getName());

if (is_link($target)) {
unlink($target);
}
}
}


Expand Down

0 comments on commit 853998a

Please sign in to comment.