aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-02-12 13:13:42 +0100
committerLaurent Bachelier <laurent@bachelier.name>2011-02-12 13:13:42 +0100
commitebbc001e126b61904cc7a35ce052aa4b1f690ee4 (patch)
tree923dd49ead38623ed66dcf35509ea0567ca310ac
parentPreliminary work to support multiple applications (diff)
downloadsymfttpd-ebbc001e126b61904cc7a35ce052aa4b1f690ee4.tar.xz
More factorization for symlink handling
-rw-r--r--lib/Symfony1.php49
-rwxr-xr-xmksymlinks37
2 files changed, 51 insertions, 35 deletions
diff --git a/lib/Symfony1.php b/lib/Symfony1.php
index 7311bc0..4866522 100644
--- a/lib/Symfony1.php
+++ b/lib/Symfony1.php
@@ -1,13 +1,17 @@
<?php
class Symfony1 extends Application
{
+ protected $version;
+
/**
* TODO if not in the root of the project, try to find it (like git does)
+ * @param string $path Project root path. If not provided, try current directory.
+ * @param string $version Symfony version: '1.0', '1.1'…
* @see Application::__construct
*
* @author Laurent Bachelier <laurent@bachelier.name>
*/
- public function __construct($project_path = null)
+ public function __construct($project_path = null, $version)
{
if ($project_path === null)
{
@@ -20,5 +24,48 @@ class Symfony1 extends Application
}
$this->project_path = $project_path;
+ $this->version = $version;
+ }
+
+ /**
+ * Find plugins with a "web" directory
+ * @param string $project_path
+ * @return array Plugin names
+ *
+ * @author Laurent Bachelier <laurent@bachelier.name>
+ */
+ public function findPlugins()
+ {
+ $plugins = array();
+ foreach (new DirectoryIterator($this->getProjectPath()."/plugins") as $file)
+ {
+ $name = $file->getFilename();
+ if ($file->isDir()
+ && preg_match('/^[^\.].+Plugin$/', $name)
+ && is_dir($this->getProjectPath().'/plugins/'.$name.'/web')
+ )
+ {
+ $plugins[] = $name;
+ }
+ }
+
+ return $plugins;
+ }
+
+ /**
+ * @return array
+ *
+ * @author Laurent Bachelier <laurent@bachelier.name>
+ */
+ public function getAvailableLinks()
+ {
+
+ return array(
+ 'symfony_symlink' => '',
+ 'lib_symlink' => 'lib',
+ 'data_symlink' => 'data',
+ 'web_symlink' => 'data/web/sf',
+ );
}
+
}
diff --git a/mksymlinks b/mksymlinks
index af38db4..cf1bcb8 100755
--- a/mksymlinks
+++ b/mksymlinks
@@ -33,31 +33,6 @@ function replace_symlink($project_path, $target, $link, $relative = true)
log_message(' '.$link.' => '.$target.($success ? '' : ' ...FAILED!'), !$success);
}
-/**
- * Find plugins with a "web" directory
- * @param string $project_path
- * @return array Plugin names
- *
- * @author Laurent Bachelier <laurent@bachelier.name>
- */
-function find_plugins($project_path)
-{
- $plugins = array();
- foreach (new DirectoryIterator($project_path."/plugins") as $file)
- {
- $name = $file->getFilename();
- if ($file->isDir()
- && preg_match('/^[^\.].+Plugin$/', $name)
- && is_dir($project_path.'/plugins/'.$name.'/web')
- )
- {
- $plugins[] = $name;
- }
- }
-
- return $plugins;
-}
-
$options = MultiConfig::get();
$options['color'] = !Argument::get('C', 'no-color', false) && posix_isatty(STDOUT);
@@ -66,7 +41,7 @@ if ($options['color'])
Color::enable();
}
-$application = new Symfony1(Argument::get('P', 'path', null));
+$application = new Symfony1(Argument::get('P', 'path', null), $options['want']);
$project_path = $application->getProjectPath();
log_message(Color::style('bright') . Color::fgColor('green')
@@ -80,13 +55,7 @@ if ($options['genconf'])
}
$sf_path = $options['sf_path'][$options['want']];
-foreach (array(
- 'symfony_symlink' => '',
- 'lib_symlink' => 'lib',
- 'data_symlink' => 'data',
- 'web_symlink' => 'data/web/sf',
- )
- as $option => $relpath)
+foreach ($application->getAvailableLinks() as $option => $relpath)
{
$link = $options[$option];
if ($link)
@@ -129,7 +98,7 @@ if ($options['do_plugins'])
log_message(Color::style('bright') . Color::fgColor('green')
. 'Creating symbolic links for plugins... (internal method)'
. Color::style('normal'));
- foreach (find_plugins($project_path) as $name)
+ foreach ($application->findPlugins() as $name)
{
$link = 'web/'.$name;
$target = $project_path.'/plugins/'.$name.'/web';