Example #1
0
 public function __construct()
 {
     parent::__construct();
     // Creating a controller service for comments
     $this->set('CommentController', function () {
         $controller = new \Phpmvc\Comment\CommentController();
         $controller->setDI($this);
         return $controller;
     });
     // Creating a model service for comments
     $this->set('comments', function () {
         //            $comments = new \Phpmvc\Comment\CommentsInSession();
         $comments = new \Phpmvc\Comment\Comment();
         $comments->setDI($this);
         return $comments;
     });
     // Database service (from mos vendor)
     $this->set('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/database_sqlite.php');
         $db->connect();
         return $db;
     });
     // Form service (from mos vendor)
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     // Controller for forms
     $this->set('FormController', function () {
         $controller = new \Anax\HTMLForm\FormController();
         $controller->setDI($this);
         return $controller;
     });
     // Controller for User-actions
     $this->set('UsersController', function () {
         $controller = new \Anax\Users\UsersController();
         $controller->setDI($this);
         return $controller;
     });
     // Request-recorder service
     $this->set('recorder', function () {
         $dbh = new \Kajja\Recorder\RequestDatabase();
         $dbh->setOptions(['dsn' => 'sqlite:' . ANAX_APP_PATH . '.htphpmvc.sqlite', 'fetch_mode' => \PDO::FETCH_ASSOC]);
         $dbh->connect();
         $formatter = new \Kajja\Recorder\HTMLFormatter();
         $recorder = new \Kajja\Recorder\RequestRecordAnax($dbh, $formatter, $this);
         return $recorder;
     });
 }
Example #2
0
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         if (isset($_SERVER['HTTP-HOST'])) {
             if ($_SERVER['HTTP-HOST'] == 'localhost') {
                 $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql.php');
             }
         } else {
             $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql_bth.php');
         }
         $db->connect();
         return $db;
     });
     $this->setShared('form', function () {
         $form = new \Mos\HTMLForm\CForm();
         $this->session;
         //$form->saveInSession = true;
         return $form;
     });
     // Set controllers
     $this->set('CommentController', function () {
         $controller = new \Phpmvc\Comment\CommentController();
         $controller->setDI($this);
         return $controller;
     });
     $this->set('UsersController', function () {
         $controller = new \Anax\Users\UsersController();
         $controller->setDI($this);
         return $controller;
     });
     $this->set('FormController', function () {
         $controller = new \Anax\HTMLForm\FormController();
         $controller->setDI($this);
         return $controller;
     });
     $this->set('logger', function () {
         $logger = new \Eden\Log\Clog();
         //$controller->setDI($logger);
         return $logger;
     });
 }
 public function __construct()
 {
     parent::__construct();
     // Inject the comment service into the app
     $this->set('CommentController', function () {
         $controller = new \Idun\Comment\CommentController();
         $controller->setDI($this);
         return $controller;
     });
     // Inject the form service into the app
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     // Inject the form controller into the app
     $this->set('FormController', function () {
         $controller = new \Anax\HTMLForm\FormController();
         $controller->setDI($this);
         return $controller;
     });
     // Inject the database service into the app
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/database_mysql.php');
         $db->connect();
         return $db;
     });
     // Inject the user and admin controller into the app
     $this->set('UsersController', function () {
         $controller = new \Idun\Users\UsersController();
         $controller->setDI($this);
         return $controller;
     });
     // Inject the forum controller into the app
     $this->set('ForumController', function () {
         $controller = new \Idun\Forum\ForumController();
         $controller->setDI($this);
         return $controller;
     });
     // Inject the forum controller into the app
     $this->set('sessionmodel', function () {
         $sessionmodel = new \Idun\Session\CSessionModel();
         $sessionmodel->setDI($this);
         return $sessionmodel;
     });
 }
Example #4
0
    return $controller;
});
$di->setShared('db', function () {
    $db = new \Mos\Database\CDatabaseBasic();
    $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql.php');
    $db->connect();
    return $db;
});
$di->set('UsersController', function () use($di) {
    $controller = new \Anax\Users\UsersController();
    $controller->setDI($di);
    return $controller;
});
$di->set('FormController', function () use($di) {
    $controller = new \Anax\HTMLForm\FormController();
    $controller->setDI($di);
    return $controller;
});
// END CONTROLLERS
// ROUTES
$app->router->add('', function () use($app) {
    $app->theme->setTitle("Min Me sida");
    $users = $app->dispatcher->forward(['controller' => 'users', 'action' => 'list']);
});
$app->router->add('list', function () use($app) {
    $users = $app->dispatcher->forward(['controller' => 'users', 'action' => 'list']);
});
$app->router->add('add', function () use($app) {
    $users = $app->dispatcher->forward(['controller' => 'Form', 'action' => 'index']);
});
$app->router->add('setup', function () use($app) {