Rewrite of initInstance(), more eval() rewritten to call_user_func_array()
[shipsimu.git] / application / selector / starter.php
index ca9d294c58dcd191054b1d56fcf03c229b3cdbdb..dab9479966f21162112209e748b68043a6127249 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Starter of the application
+ * The application launcher
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -22,8 +22,9 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// Get the application helper instance
-$app = ApplicationHelper::getInstance();
+// Is there an application helper instance? We need the method main() for
+// maining the application
+$app = call_user_func_array(array(FrameworkConfiguration::getInstance()->readConfig('app_helper_class'), "getInstance"), array());
 
 // Some sanity checks
 if ((empty($app)) || (is_null($app))) {
@@ -47,11 +48,8 @@ if ((empty($app)) || (is_null($app))) {
 
 // Call the entry point method
 try {
-       $eval = sprintf("%s::getInstance()->%s();",
-               FrameworkConfiguration::getInstance()->readConfig('app_helper_class'),
-               FrameworkConfiguration::getInstance()->readConfig('entry_method')
-       );
-       eval($eval);
+       // Call user function
+       call_user_func_array(array($app, FrameworkConfiguration::getInstance()->readConfig('entry_method')), array());
 } catch (FrameworkException  $e) {
        ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> could not be launched for the follwing reason: <strong>%s</strong>",
                $application,