Beispiel #1
0
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/database/config_mysql.php');
         $db->connect();
         return $db;
     });
     $this->setShared('auth', function () {
         $auth = new \Anax\Auth\Auth();
         return $auth;
     });
     $this->setShared('form', function () {
         $form = new \Mos\HTMLForm\CForm();
         return $form;
     });
     $this->setShared('gravatar', function () {
         $gravatar = new \Anax\User\Gravatar();
         return $gravatar;
     });
     $this->setShared('user', function () {
         $form = new \Anax\User\User();
         return $form;
     });
     $this->setShared('tags', function () {
         $tags = new \Anax\Tag\Tag();
         return $tags;
     });
 }
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     // Add CDatabase to framework
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         // LOCALp
         $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql.php');
         // BTH
         // $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql_bth.php');
         $db->connect();
         return $db;
     });
     // Add CForm to framework
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     // Create extra navbar for top menu
     $this->setShared('topnav', function () {
         $navbar = new \Anax\Navigation\CNavbar();
         $navbar->setDI($this);
         $navbar->configure(ANAX_APP_PATH . 'config/topnav.php');
         return $navbar;
     });
     // Add UserController to framework
     $this->set('UserController', function () {
         $controller = new \Anax\User\UserController();
         $controller->setDI($this);
         return $controller;
     });
     // Add QuestionsController to framework
     $this->set('QuestionsController', function () {
         $controller = new \Anax\Questions\QuestionsController();
         $controller->setDI($this);
         $controller->setup();
         return $controller;
     });
     // Add AnswersController to framework
     $this->set('AnswersController', function () {
         $controller = new \Anax\Answers\AnswersController();
         $controller->setDI($this);
         $controller->setup();
         return $controller;
     });
     // Add CommentsController to framework
     $this->set('CommentsController', function () {
         $controller = new \Anax\Comments\CommentsController();
         $controller->setDI($this);
         $controller->setup();
         return $controller;
     });
     // Add TagsController to framework
     $this->set('TagsController', function () {
         $controller = new \Anax\Tags\TagsController();
         $controller->setDI($this);
         $controller->setup();
         return $controller;
     });
 }
Beispiel #3
0
 public function __construct()
 {
     parent::__construct();
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/database_sqlite.php');
         $db->connect();
         return $db;
     });
 }
 public function testNoneExistingMethod()
 {
     $survey = new \Idun\Survey\SurveyController();
     $di = new \Anax\DI\CDIFactoryDefault();
     $survey->setDI($di);
     // Inject the database service
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'some_database_file');
         $db->connect();
         return $db;
     });
 }
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     // Add forms service
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     // Add databas service as a singleton
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/database_mysql.php');
         $db->connect();
         return $db;
     });
 }
Beispiel #6
0
 /**
  * Test
  *
  * @return void
  *
  */
 public static function setUpBeforeClass()
 {
     $di = new \Anax\DI\CDIFactoryDefault();
     $di->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(['dsn' => "sqlite:memory::", 'debug_connect' => true]);
         $db->connect();
         return $db;
     });
     self::$movie = new \Jovis\DatabaseModel\Movie();
     self::$movie->setDI($di);
     self::$movie->init();
 }
Beispiel #7
0
 /**
  * Basic setup of the mock database to perform tests against.
  *
  */
 public static function setUpBeforeClass()
 {
     self::$di = new \Anax\DI\CDIFactoryDefault();
     self::$app = new \Anax\MVC\CApplicationBasic(self::$di);
     self::$di->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(['dsn' => "sqlite:memory::", "verbose" => false]);
         $db->connect();
         $db->dropTableIfExists('content')->execute();
         $db->createTable('content', ['id' => ['integer', 'primary key', 'not null', 'auto_increment'], 'slug' => ['varchar(80)', 'unique'], 'url' => ['varchar(80)', 'unique'], 'type' => ['varchar(80)'], 'title' => ['varchar(80)'], 'data' => ['text'], 'filter' => ['char(80)'], 'created' => ['datetime'], 'published' => ['datetime'], 'updated' => ['datetime'], 'deleted' => ['datetime'], 'owner' => ['varchar(80)'], 'updated_by' => ['varchar(80)']])->execute();
         $now = gmdate('Y-m-h H:i:s');
         $db->insert('content', ['slug', 'type', 'title', 'data', 'created', 'published', 'owner']);
         $db->execute(['a-first-article', 'article', 'A first article', 'This is the text of the first article.', $now, $now, 'admin']);
         return $db;
     });
 }
Beispiel #8
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;
     });
 }
 /**
  * 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;
     });
 }
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->setShared('theme', function () {
         $themeEngine = new \Anax\ThemeEngine\CThemeExtended();
         $themeEngine->setDI($this);
         $themeEngine->configure(ANAX_APP_PATH . 'config/theme.php');
         return $themeEngine;
     });
     // Forms service
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     // Database service for Anax
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/config_sqlite.php');
         $db->connect();
         return $db;
     });
     // Flash messages
     $this->setShared('flashmessage', function () {
         $flashmessages = new \helikopterspark\FlashMsg\FlashMsg();
         $flashmessages->setDI($this);
         return $flashmessages;
     });
     // Comments
     $this->set('CommentsController', function () {
         $commentscontroller = new \CR\Comment\CommentsController();
         $commentscontroller->setDI($this);
         return $commentscontroller;
     });
     // Users
     $this->set('UsersController', function () {
         $userscontroller = new \Anax\Users\UsersController();
         $userscontroller->setDI($this);
         return $userscontroller;
     });
     $this->setShared('logger', function () {
         $logger = new \Toeswade\Log\Clog();
         return $logger;
     });
 }
Beispiel #12
0
<?php

require __DIR__ . '/config_with_app.php';
$di->setShared('db', function () {
    $db = new \Mos\Database\CDatabaseBasic();
    $db->setOptions(require ANAX_APP_PATH . 'config/database_sqlite.php');
    $db->connect();
    return $db;
});
$di->set('UsersController', function () use($di) {
    $controller = new \Anax\Users\UsersController();
    $controller->setDI($di);
    return $controller;
});
// $app->router->add('setup', function () use ($app) {
//
//     $app->db->setVerbose();
//
//     $app->db->dropTableIfExists('user')->execute();
//
//     $app->db->createTable(
//         'user',
//         [
//             'id' => ['integer', 'primary key', 'not null', 'auto_increment'],
//             'acronym' => ['varchar(20)', 'unique', 'not null'],
//             'email' => ['varchar(80)'],
//             'name' => ['varchar(80)'],
//             'password' => ['varchar(255)'],
//             'created' => ['datetime'],
//             'updated' => ['datetime'],
//             'deleted' => ['datetime'],
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->setShared('theme', function () {
         $themeEngine = new \CR\ThemeEngine\CThemeExtended();
         $themeEngine->setDI($this);
         $themeEngine->configure(ANAX_APP_PATH . 'config/theme.php');
         return $themeEngine;
     });
     // Forms service
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     // Database service for Anax
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql_wgtotw.php');
         $db->connect();
         return $db;
     });
     // Flash messages
     $this->setShared('flashmessage', function () {
         $flashmessages = new \helikopterspark\FlashMsg\FlashMsg();
         $flashmessages->setDI($this);
         return $flashmessages;
     });
     // Questions
     $this->setShared('QuestionController', function () {
         $questions = new \CR\Question\QuestionController();
         $questions->setDI($this);
         return $questions;
     });
     // Answers
     $this->setShared('AnswerController', function () {
         $answers = new \CR\Answer\AnswerController();
         $answers->setDI($this);
         return $answers;
     });
     // Tags
     $this->setShared('TagController', function () {
         $tags = new \CR\Tag\TagController();
         $tags->setDI($this);
         return $tags;
     });
     // Comments
     $this->set('CommentsController', function () {
         $commentscontroller = new \CR\Comment\CommentsController();
         $commentscontroller->setDI($this);
         return $commentscontroller;
     });
     // Users
     $this->set('UsersController', function () {
         $userscontroller = new \CR\Users\UsersController();
         $userscontroller->setDI($this);
         return $userscontroller;
     });
     // User login
     $this->set('UserloginController', function () {
         $userlogincontroller = new \CR\Users\UserloginController();
         $userlogincontroller->setDI($this);
         return $userlogincontroller;
     });
     // Paginator
     $this->setShared('paginator', function () {
         $paginate = new \CR\Paginator\CPaginator();
         $paginate->setDI($this);
         return $paginate;
     });
     // Vote service
     $this->setShared('vote', function () {
         $votes = new \CR\Vote\Vote();
         $votes->setDI($this);
         return $votes;
     });
     // Topbar
     $this->setShared('topbar', function () {
         $topbar = new \CR\Topbar\CTopbar();
         $topbar->setDI($this);
         //$topbar->configure(ANAX_APP_PATH . 'config/navbar.php');
         return $topbar;
     });
 }
Beispiel #14
0
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     require ANAX_APP_PATH . 'config/error_reporting.php';
     $this->setShared('response', '\\Anax\\Response\\CResponseBasic');
     $this->setShared('validate', '\\Anax\\Validate\\CValidate');
     $this->setShared('flash', '\\Anax\\Flash\\CFlashBasic');
     $this->set('route', '\\Anax\\Route\\CRouteBasic');
     $this->set('view', '\\Anax\\View\\CViewBasic');
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     $this->set('ErrorController', function () {
         $controller = new \Anax\MVC\ErrorController();
         $controller->setDI($this);
         return $controller;
     });
     $this->setShared('log', function () {
         $log = new \Anax\Log\CLogger();
         $log->setContext('development');
         return $log;
     });
     $this->setShared('request', function () {
         $request = new \Anax\Request\CRequestBasic();
         $request->init();
         return $request;
     });
     $this->setShared('url', function () {
         $url = new \Anax\Url\CUrl();
         $url->setSiteUrl($this->request->getSiteUrl());
         $url->setBaseUrl($this->request->getBaseUrl());
         $url->setStaticSiteUrl($this->request->getSiteUrl());
         $url->setStaticBaseUrl($this->request->getBaseUrl());
         $url->setScriptName($this->request->getScriptName());
         $url->setUrlType($url::URL_APPEND);
         return $url;
     });
     $this->setShared('views', function () {
         $views = new \Anax\View\CViewContainerBasic();
         $views->setBasePath(ANAX_APP_PATH . 'view');
         $views->setFileSuffix('.tpl.php');
         $views->setDI($this);
         return $views;
     });
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql.php');
         $db->connect();
         return $db;
     });
     $this->setShared('router', function () {
         $router = new \Anax\Route\CRouterBasic();
         $router->setDI($this);
         $router->addInternal('403', function () {
             $this->dispatcher->forward(['controller' => 'error', 'action' => 'statusCode', 'params' => ['code' => 403, 'message' => "HTTP Status Code 403: This is a forbidden route."]]);
         })->setName('403');
         $router->addInternal('404', function () {
             $this->dispatcher->forward(['controller' => 'error', 'action' => 'statusCode', 'params' => ['code' => 404, 'message' => "HTTP Status Code 404: This route is not found."]]);
             $this->dispatcher->forward(['controller' => 'error', 'action' => 'displayValidRoutes']);
         })->setName('404');
         $router->addInternal('500', function () {
             $this->dispatcher->forward(['controller' => 'error', 'action' => 'statusCode', 'params' => ['code' => 500, 'message' => "HTTP Status Code 500: There was an internal server or processing error."]]);
         })->setName('500');
         return $router;
     });
     $this->setShared('dispatcher', function () {
         $dispatcher = new \Anax\MVC\CDispatcherBasic();
         $dispatcher->setDI($this);
         return $dispatcher;
     });
     $this->setShared('session', function () {
         $session = new \Anax\Session\CSession();
         $session->configure(ANAX_APP_PATH . 'config/session.php');
         $session->name();
         $session->start();
         return $session;
     });
     $this->setShared('theme', function () {
         $themeEngine = new \Anax\ThemeEngine\CThemeBasic();
         $themeEngine->setDI($this);
         $themeEngine->configure(ANAX_APP_PATH . 'config/theme.php');
         return $themeEngine;
     });
     $this->setShared('navbar', function () {
         $navbar = new \Anax\Navigation\CNavbar();
         $navbar->setDI($this);
         $navbar->configure(ANAX_APP_PATH . 'config/navbar.php');
         return $navbar;
     });
     $this->setShared('user', function () {
         $user = new \Anax\Users\User();
         $user->setDI($this);
         return $user;
     });
     $this->set('fileContent', function () {
         $fc = new \Anax\Content\CFileContent();
         $fc->setBasePath(ANAX_APP_PATH . 'content/');
         return $fc;
     });
     $this->setShared('textFilter', function () {
         $filter = new \Anax\Content\CTextFilter();
         $filter->setDI($this);
         $filter->configure(ANAX_APP_PATH . 'config/text_filter.php');
         return $filter;
     });
 }
 /**
  * Construct.
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->setShared('theme', function () {
         $themeEngine = new \CR\ThemeEngine\CThemeExtended();
         $themeEngine->setDI($this);
         $themeEngine->configure(ANAX_APP_PATH . 'config/theme-grid.php');
         return $themeEngine;
     });
     // Forms service
     $this->set('form', '\\Mos\\HTMLForm\\CForm');
     // Database service for Anax
     $this->setShared('db', function () {
         $db = new \Mos\Database\CDatabaseBasic();
         $db->setOptions(require ANAX_APP_PATH . 'config/config_mysql_wgtotw.php');
         $db->connect();
         return $db;
     });
     // Flash messages
     $this->setShared('flashmessage', function () {
         $flashmessages = new \helikopterspark\FlashMsg\FlashMsg();
         $flashmessages->setDI($this);
         return $flashmessages;
     });
     // Paginator
     $this->setShared('paginator', function () {
         $paginate = new \CR\Paginator\CPaginator();
         $paginate->setDI($this);
         return $paginate;
     });
     // Topbar
     $this->setShared('topbar', function () {
         $topbar = new \CR\Topbar\CTopbar();
         $topbar->setDI($this);
         //$topbar->configure(ANAX_APP_PATH . 'config/navbar.php');
         return $topbar;
     });
     // Shop
     $this->setShared('ShopController', function () {
         $shop = new \CR\JSShop\ShopController();
         $shop->setDI($this);
         return $shop;
     });
     // Checkout
     $this->setShared('CheckoutController', function () {
         $checkout = new \CR\JSShop\CheckoutController();
         $checkout->setDI($this);
         return $checkout;
     });
     // Playgrounds
     $this->setShared('CkmomController', function () {
         $kmom = new \CR\CKmom\CkmomController();
         $kmom->setDI($this);
         return $kmom;
     });
     // Websockets
     $this->setShared('WebsocketsController', function () {
         $ws = new \CR\Websockets\WebsocketsController();
         $ws->setDI($this);
         return $ws;
     });
 }