aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-03-15 00:51:51 +0100
committerLaurent Bachelier <laurent@bachelier.name>2011-03-15 00:51:51 +0100
commitea7c90839f4b82be5686f662d1b36b9f484a9e6b (patch)
treeadcefe518d3c4980655b2f4507992b0a13c9808c
parentMerge branch 'master' into multiapp (diff)
downloadsymfttpd-ea7c90839f4b82be5686f662d1b36b9f484a9e6b.tar.xz
Move the discovery of available applications to the Symfony1 class
-rw-r--r--lib/Symfony1.php19
-rwxr-xr-xspawn11
2 files changed, 20 insertions, 10 deletions
diff --git a/lib/Symfony1.php b/lib/Symfony1.php
index 4866522..1d5a866 100644
--- a/lib/Symfony1.php
+++ b/lib/Symfony1.php
@@ -68,4 +68,23 @@ class Symfony1 extends Application
);
}
+ /**
+ * @return array Filenames of the apps, e.g. array('frontend.php', 'backend.php')
+ *
+ * @author Laurent Bachelier <laurent@bachelier.name>
+ */
+ public function getApps()
+ {
+ $applications = array();
+ foreach (new DirectoryIterator($this->project_path.'/web') as $file)
+ {
+ if ($file->isFile() && preg_match('/\.php$/', $file->getFilename()))
+ {
+ $apps[] = $file->getFilename();
+ }
+ }
+ sort($apps);
+
+ return $apps;
+ }
}
diff --git a/spawn b/spawn
index 7cbb076..cbc87af 100755
--- a/spawn
+++ b/spawn
@@ -97,19 +97,10 @@ log_message('lighttpd started on '
. Color::style('bright') . $options['port'] . Color::style('normal')
. '.');
log_message("\nAvailable applications:");
-$apps = array();
-foreach (new DirectoryIterator($project_path.'/web') as $file)
-{
- if ($file->isFile() && preg_match('/\.php$/', $file->getFilename()))
- {
- $apps[] = $file->getFilename();
- }
-}
$host = in_array($options['bind'], array(false, '0.0.0.0', '::'), true)
? 'localhost'
: $options['bind'];
-sort($apps);
-foreach ($apps as $app)
+foreach ($application->getApps() as $app)
{
log_message(' http://'.$host.':'.$options['port']
.'/'.Color::style('bright').$app.Color::style('normal'));