Example #1
0
 public function __construct($autoloadManager, $eventManager)
 {
     $this->autoloadManager = $autoloadManager;
     $this->eventManager = $eventManager;
     foreach (Config::read('modules') as $name => $dir) {
         $this->loadModule($name, $dir);
     }
 }
Example #2
0
 public function __construct(Application $application)
 {
     $this->application = $application;
     foreach (Config::read('components') as $name => $callback) {
         if (is_string($callback)) {
             $this->load($name, new $callback($this->application));
         } else {
             $this->load($name, $callback($this->application));
         }
     }
     $this->onBoostrap();
 }
Example #3
0
 public function __construct()
 {
     foreach (Config::read('components') as $key => $className) {
         $this->load($key, new $className());
     }
 }
Example #4
0
 */
/*
 *	Specifics configurations
 */
require 'db.config.php';
// require MyVendorName.config.php
// This required file doesn't need to be modified, all configurations for the boostrap is defined in this current page
require 'bootstrap.config.php';
use Fk\Config\Config;
use Fk\Cache\Cache;
use Fk\Route\Router;
/*
 *	All cache configuration
 */
Cache::setDefaultDuration(60);
Cache::setDefaultDirname('/data/cache/');
Config::write('cache', ['path' => null, 'duration' => null]);
Config::write('kernel.cache', ['path' => null, 'duration' => null]);
// Router::setUrlPattern([
// 	Router::$LANG_CODE => true,
// 	Router::$CONTROLLER_CODE => true,
// 	Router::$ACTION_CODE => true,
// 	Router::$PARAMS_CODE => true,
// ], false);
Router::setDefaultsRoutes('Home', 'index');
Config::write('helpers', ['Auth' => 'Fk\\View\\Helper\\Adapter\\Auth', 'Session' => 'Fk\\View\\Helper\\Adapter\\Session', 'Cache' => 'Fk\\Cache\\Cache', 'Log' => 'Fk\\Log\\Log', 'Filter' => 'Fk\\Filter\\Filter', 'Form' => 'Fk\\Form\\FormHelper']);
Config::write('modules', ['App' => 'app/']);
Config::write('langs', ['autorized' => ['fr', 'en', 'pt', 'us'], 'default' => 'fr']);
Config::write('kernel.params_to_controller_mode', 'linear');
Config::write('kernel.debug_mode', 1);
Example #5
0
 public static function run($uri = null)
 {
     $application = new Application();
     $application->setCache(new Cache(Config::read('kernel.cache.path'), Config::read('kernel.cache.duration')))->setEventManager(new EventManager())->setAutoLoadManager(new AutoLoadManager())->setModuleManager(new ModuleManager($application->getAutoloadManager(), $application->getEventManager()))->setRequest(new Request(new Uri($uri)))->dispatch();
 }
Example #6
0
<?php

use Fk\Config\Config;
use Fk\Cache\Cache;
Config::write('components', ['Request' => function ($application) {
    return $application->getRequest();
}, 'Response' => 'Fk\\Http\\Response\\Response', 'Session' => 'Fk\\Session\\Session', 'Model' => 'Fk\\ORM\\TableManager', 'Cache' => function ($application) {
    return new Cache(Config::read('cache.path'), Config::read('cache.duration'));
}]);
Example #7
0
 public static function getRoute(Uri $uri)
 {
     $route = new Route();
     $path = self::getRewrittenPath($uri->getPathString());
     // Set the namespace
     if (count($path) > 0) {
         if (array_key_exists($path[0], self::getNamespaces())) {
             $namespace = self::getNamespace($path[0]);
             $namespaceUrl = $path[0] . '/';
             $path = array_slice($path, 1);
         } else {
             $namespace = self::getNamespace('_default');
             $namespaceUrl = '';
         }
     } else {
         header('Location:/' . Config::read('langs.default') . '/');
     }
     $route->setModuleName(current(explode('\\', ltrim($namespace, '\\'))));
     // Cause the maduleName is the first of all namespaces
     // Set the lang
     $langs = Config::read('langs');
     if (count($path) > 0) {
         if (in_array($path[0], $langs['autorized'])) {
             $route->setLang($path[0]);
             $path = array_values(array_slice($path, 1));
         } else {
             header('Location:/' . $namespaceUrl . $langs['default']);
             //.'/'.implode('/', array_slice($path, 1)));
         }
     } else {
         header('Location:/' . $namespaceUrl . $langs['default']);
         //.'/'.implode('/', $path));
     }
     // Set the controller name
     if (count($path) > 0) {
         $controllerName = $namespace . '\\' . ucfirst(strtolower($path[0]));
         $path = array_values(array_slice($path, 1));
     } else {
         $controllerName = $namespace . '\\' . self::$defaultController;
     }
     $route->setControllerName($controllerName);
     // Set the action name
     if (count($path) > 0) {
         $route->setActionName(strtolower($path[0]) . 'Action');
     } else {
         $route->setActionName(self::$defaultAction . 'Action');
     }
     // Set parameters
     $route->setParams(array_slice($path, 1));
     return $route;
     // $pattern = explode("?", $pattern);
     // $pattern = $pattern[0];
     // if($route = self::findPattern(preg_replace("#{([".self::$_regex."]+)}#i", "{}", $pattern), true)) {
     // 	$tab = preg_split("#[{}]#i", $route["pattern"]);
     // 	if(count($tab) > 1) {
     // 		foreach ($tab as $key => $value) {
     // 			if($key%2 == 1)
     // 				$paramsName[] = $value;
     // 			else
     // 				$pattern = str_replace($value, "%", $pattern);
     // 		}
     // 		$paramsValue = explode("%", $pattern);
     // 		foreach ($paramsName as $key => $value)
     // 			$params[$value] = $paramsValue[$key+1];
     // 	}
     // 	else
     // 		$params = array();
     // 	return array("controller" => $route["controller"], "action" => $route["action"], "params" => $params);
     // }
     // else {
     // 	$route = array_values(array_filter(explode("/", $pattern)));
     // 	return array(
     // 			"controller" => (array_key_exists(0, $route)) ? $route[0] : self::$_defaultController,
     // 			"action" => (array_key_exists(1, $route)) ? $route[1] : self::$_defaultAction,
     // 			"params" => array_slice($route, 2),
     // 		);
     // }
 }