aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-02-09 00:37:35 +0100
committerLaurent Bachelier <laurent@bachelier.name>2011-02-09 00:40:12 +0100
commit0f2a1b6244d78bf8ddb5045801f558eabb997b75 (patch)
tree12e4850d344af167870228a09f8e873811ab87ad
parentColorize mksymlinks output (diff)
downloadsymfttpd-0f2a1b6244d78bf8ddb5045801f558eabb997b75.tar.xz
Preliminary work to support multiple applications
Symfony1 is now a standard class. It is now decoupled from the Argument static class. There is still much work to be done to move everything related to Symfony1 to that class.
-rw-r--r--lib/Application.php22
-rw-r--r--lib/Symfony.php22
-rw-r--r--lib/Symfony1.php24
-rwxr-xr-xmksymlinks6
-rwxr-xr-xspawn6
5 files changed, 54 insertions, 26 deletions
diff --git a/lib/Application.php b/lib/Application.php
new file mode 100644
index 0000000..693bf6f
--- /dev/null
+++ b/lib/Application.php
@@ -0,0 +1,22 @@
+<?php
+abstract class Application
+{
+ protected $project_path;
+
+ /**
+ * @param string $path Project root path. If not provided, try current directory.
+ */
+ abstract public function __construct($project_path = null);
+
+ /**
+ * Get the current project's root path
+ * @return string Absolute path
+ *
+ * @author Laurent Bachelier <laurent@bachelier.name>
+ */
+ public function getProjectPath()
+ {
+
+ return $this->project_path;
+ }
+}
diff --git a/lib/Symfony.php b/lib/Symfony.php
deleted file mode 100644
index 190c464..0000000
--- a/lib/Symfony.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-class Symfony
-{
- /**
- * Get the current project's root path
- * @return string Absolute path
- *
- * TODO if not in the root of the project, try to find it (like git does)
- *
- * @author Laurent Bachelier <laurent@bachelier.name>
- */
- static public function getProjectPath()
- {
- $project_path = realpath(Argument::get('P', 'path', getcwd()));
- if (!is_file($project_path.'/symfony'))
- {
- throw new Exception('Not in a symfony project');
- }
-
- return $project_path;
- }
-}
diff --git a/lib/Symfony1.php b/lib/Symfony1.php
new file mode 100644
index 0000000..7311bc0
--- /dev/null
+++ b/lib/Symfony1.php
@@ -0,0 +1,24 @@
+<?php
+class Symfony1 extends Application
+{
+ /**
+ * TODO if not in the root of the project, try to find it (like git does)
+ * @see Application::__construct
+ *
+ * @author Laurent Bachelier <laurent@bachelier.name>
+ */
+ public function __construct($project_path = null)
+ {
+ if ($project_path === null)
+ {
+ $project_path == getcwd();
+ }
+ $project_path = realpath($project_path);
+ if (!is_file($project_path.'/symfony'))
+ {
+ throw new Exception('Not in a symfony project');
+ }
+
+ $this->project_path = $project_path;
+ }
+}
diff --git a/mksymlinks b/mksymlinks
index fee8192..af38db4 100755
--- a/mksymlinks
+++ b/mksymlinks
@@ -6,7 +6,8 @@
require(dirname(__FILE__).'/lib/bootstrap.php');
require(dirname(__FILE__).'/lib/FileTools.php');
require(dirname(__FILE__).'/lib/MultiConfig.php');
-require(dirname(__FILE__).'/lib/Symfony.php');
+require(dirname(__FILE__).'/lib/Application.php');
+require(dirname(__FILE__).'/lib/Symfony1.php');
require(dirname(__FILE__).'/lib/Argument.php');
require(dirname(__FILE__).'/lib/Color.php');
@@ -65,7 +66,8 @@ if ($options['color'])
Color::enable();
}
-$project_path = Symfony::getProjectPath();
+$application = new Symfony1(Argument::get('P', 'path', null));
+$project_path = $application->getProjectPath();
log_message(Color::style('bright') . Color::fgColor('green')
. 'Using symfony version ' . Color::style('normal')
diff --git a/spawn b/spawn
index 507b933..4a67e33 100755
--- a/spawn
+++ b/spawn
@@ -9,11 +9,13 @@ require dirname(__FILE__).'/lib/Template.php';
require dirname(__FILE__).'/lib/FileTools.php';
require dirname(__FILE__).'/lib/PosixTools.php';
require dirname(__FILE__).'/lib/MultiConfig.php';
-require dirname(__FILE__).'/lib/Symfony.php';
+require dirname(__FILE__).'/lib/Application.php';
+require dirname(__FILE__).'/lib/Symfony1.php';
require dirname(__FILE__).'/lib/Tail.php';
require dirname(__FILE__).'/lib/Color.php';
-$project_path = Symfony::getProjectPath();
+$application = new Symfony1(Argument::get('P', 'path', null));
+$project_path = $application->getProjectPath();
$options = MultiConfig::get();
$options['port'] = intval(Argument::get('p', 'port', 4042));