/** * Constructor * * @param array $userSettings Associative array of application settings */ public function __construct($UserSettings = null) { # Check if the apllication is installed $this->isInstalled = !file_exists(__DIR__ . '/Install.php') && file_exists(__DIR__ . '/Config.php'); # Halt if the application is not installed if (!$this->isInstalled) { return; } # Setup IoC container $this->Container = new \Kanso\Helper\Container(); # Default settings $this->Container->singleton('Settings', function () { return new \Kanso\Config\Settings(); }); # Initialize application configuration $this->Container['Config'] = $this->Settings->get(); # Default environment $this->Container->singleton('Environment', function () { return \Kanso\Environment::extract(); }); # Default headers $this->Container->singleton('Headers', function () { return \Kanso\Http\Headers::extract(); }); # Default request $this->Container->singleton('Request', function () { return new \Kanso\Http\Request(); }); # Default response $this->Container->singleton('Response', function () { return new \Kanso\Http\Response(); }); # Default databse $this->Container->singleton('Database', function () { return new \Kanso\Database\Database(); }); # Default Gatekeeper $this->Container->singleton('Gatekeeper', function () { return new \Kanso\Auth\Gatekeeper(); }); # Default Session $this->Container->singleton('Session', function () { return new \Kanso\Auth\Session(); }); # Default GUMP $this->Container->set('Validation', function () { return new \Kanso\Utility\GUMP(); }); # Default router $this->Container->singleton('Router', function () { return new \Kanso\Router\Router(); }); # Default Query $this->Container->singleton('Query', function () { return new View\Query(); }); # Default view $this->Container->singleton('View', function () { return \Kanso\View\View::getInstance(); }); # Default view $this->Container->singleton('Cache', function () { return new \Kanso\Cache\Cache(); }); # Default Events $this->Container->singleton('Events', function () { return \Kanso\Events::getInstance(); }); # Default Filters $this->Container->singleton('Filters', function () { return \Kanso\Filters::getInstance(); }); # Default Articlekeeper $this->Container->singleton('Bookkeeper', function () { return new \Kanso\Articles\Bookkeeper(); }); # Default Comment manager $this->Container->singleton('Comments', function () { return new Kanso\Comments\CommentManager(); }); # Default FileSystem $this->Container->singleton('FileSystem', function () { return new Kanso\Utility\FileSystem(); }); # Default Humanizer $this->Container->singleton('Humanizer', function () { return new Kanso\Utility\Humanizer(); }); # Default Mailer $this->Container->singleton('Mailer', function () { return new Kanso\Utility\Mailer(); }); # Make default if first instance if (is_null(static::getInstance())) { $this->setName('default'); } # Start the session immediately $this->dispatchSession(); # Default this is not an admin request $this->is_admin = false; # Include the active theme's plugins.php file if it exists $plugins = $this->Environment['KANSO_THEME_DIR'] . DIRECTORY_SEPARATOR . $this->Config['KANSO_THEME_NAME'] . DIRECTORY_SEPARATOR . 'plugins.php'; if (file_exists($plugins)) { require_once $plugins; } }