コード例 #1
0
ファイル: ModuleManager.php プロジェクト: fozeek/framework
 public function __construct($autoloadManager, $eventManager)
 {
     $this->autoloadManager = $autoloadManager;
     $this->eventManager = $eventManager;
     foreach (Config::read('modules') as $name => $dir) {
         $this->loadModule($name, $dir);
     }
 }
コード例 #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();
 }
コード例 #3
0
ファイル: ComponentManager.php プロジェクト: fozeek/framework
 public function __construct()
 {
     foreach (Config::read('components') as $key => $className) {
         $this->load($key, new $className());
     }
 }
コード例 #4
0
ファイル: Application.php プロジェクト: fozeek/framework
 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();
 }
コード例 #5
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'));
}]);
コード例 #6
0
ファイル: Router.php プロジェクト: fozeek/framework
 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),
     // 		);
     // }
 }