aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-06-20 00:22:49 +0200
committerLaurent Bachelier <laurent@bachelier.name>2011-06-20 00:22:49 +0200
commit0918a178011e9ca096d319f84f137a76f63d01d5 (patch)
tree11862cf5c57780ee95f9815eb08ed0144ef072d2
parentLet's be bold. Start using the symfttpd directory inside a project. (diff)
downloadsymfttpd-0918a178011e9ca096d319f84f137a76f63d01d5.tar.xz
Remove getcwd() calls from lib classes
This also takes into account the right configuration file when using the --path arguments.
-rw-r--r--lib/MultiConfig.php10
-rw-r--r--lib/Symfony1.php6
-rwxr-xr-xmksymlinks4
-rwxr-xr-xspawn4
4 files changed, 11 insertions, 13 deletions
diff --git a/lib/MultiConfig.php b/lib/MultiConfig.php
index 5b5d1d8..a1645ab 100644
--- a/lib/MultiConfig.php
+++ b/lib/MultiConfig.php
@@ -3,14 +3,16 @@ class MultiConfig
{
/**
* Get config options from multiple files
+ * @param $project_path Path of the current project
+ * @param $cfgname Base name of the configuration file.
* @return array
*
* @author Laurent Bachelier <laurent@bachelier.name>
*/
- static public function get($cfgname = 'symfttpd.conf.php')
+ static public function get($project_path, $cfgname = 'symfttpd.conf.php')
{
$options = array();
- if (file_exists(getcwd().'/symfttpd') && is_dir(getcwd().'/symfttpd'))
+ if (file_exists($project_path.'/symfttpd') && is_dir($project_path.'/symfttpd'))
{
$options['has_symfttpd_dir'] = true;
}
@@ -18,8 +20,8 @@ class MultiConfig
$configs = array(
dirname(__FILE__).'/../'.$cfgname, // defaults
getenv('HOME').'/.'.$cfgname, // user configuration
- getcwd().'/config/'.$cfgname, // project configuration
- getcwd().'/symfttpd/'.$cfgname, // project configuration, new style
+ $project_path.'/config/'.$cfgname, // project configuration
+ $project_path.'/symfttpd/'.$cfgname, // project configuration, new style
);
foreach ($configs as $config)
diff --git a/lib/Symfony1.php b/lib/Symfony1.php
index 75312bf..f406c84 100644
--- a/lib/Symfony1.php
+++ b/lib/Symfony1.php
@@ -11,12 +11,8 @@ class Symfony1 extends Application
*
* @author Laurent Bachelier <laurent@bachelier.name>
*/
- public function __construct($project_path = null, $version)
+ public function __construct($project_path, $version)
{
- if ($project_path === null)
- {
- $project_path == getcwd();
- }
$project_path = realpath($project_path);
if (!is_file($project_path.'/symfony'))
{
diff --git a/mksymlinks b/mksymlinks
index cf1bcb8..9cbfeb5 100755
--- a/mksymlinks
+++ b/mksymlinks
@@ -34,14 +34,14 @@ function replace_symlink($project_path, $target, $link, $relative = true)
}
-$options = MultiConfig::get();
+$options = MultiConfig::get(Argument::get('P', 'path', getcwd()));
$options['color'] = !Argument::get('C', 'no-color', false) && posix_isatty(STDOUT);
if ($options['color'])
{
Color::enable();
}
-$application = new Symfony1(Argument::get('P', 'path', null), $options['want']);
+$application = new Symfony1(Argument::get('P', 'path', getcwd()), $options['want']);
$project_path = $application->getProjectPath();
log_message(Color::style('bright') . Color::fgColor('green')
diff --git a/spawn b/spawn
index 8a313d0..e8925f6 100755
--- a/spawn
+++ b/spawn
@@ -14,8 +14,8 @@ require dirname(__FILE__).'/lib/Symfony1.php';
require dirname(__FILE__).'/lib/Tail.php';
require dirname(__FILE__).'/lib/Color.php';
-$options = MultiConfig::get();
-$application = new Symfony1(Argument::get('P', 'path', null), $options['want']);
+$options = MultiConfig::get(Argument::get('P', 'path', getcwd()));
+$application = new Symfony1(Argument::get('P', 'path', getcwd()), $options['want']);
$project_path = $application->getProjectPath();
$options['port'] = intval(Argument::get('p', 'port', 4042));