Version 0.3 beta 04.02.2018

Improved: The Router now accepts actions, either trough the _action as parameter, or on the URL pattern after the controller name Example: http://youdomain/[controllername]/[actionname]/
It is now possible to load as many navigations on the page as wanted by passing the name to the JsonNavigation::getInstance()->loadJsonNavigationArray('[NAME]'); call in the navigationAction of the Controller
Building forms by simple adding the namespace use Nibiru\Factory\Form; and calling Example: Form::addInputTypeText( array( 'name' => 'lastname', 'value' => 'placeholder' ) ); To finalize the form the last call should be something like this: Form::addForm( array('name' => 'testform', 'method' => 'post', 'action' => '/' . Router::getInstance()->currentPage(), 'target' => '_self') );
The Database design has fully been refactored, now it contains an autoloading mechanism which can be triggert by createing a database folder in the application folder, a Example file is in the folder applicatoin/database
The Database access can now be implemented anywhere in your application by adding the namespace to your database accessing Logic: use Nibiru\Factory\Db;
This commit is contained in:
Stephan Kasdorf
2018-02-04 22:16:21 +01:00
parent 16d86ad95e
commit 86433af5bf
39 changed files with 2292 additions and 232 deletions

View File

@@ -16,6 +16,7 @@ class Router extends Config
private static $_instance;
private static $_cur_page;
private static $_routes = array();
private static $_action;
protected function __construct()
{
@@ -33,8 +34,9 @@ class Router extends Config
private static function loadRouting()
{
Config::setConfig(Config::getInstance()->getEnv());
self::$_routing = Config::getInstance()->getConfig()[View::ATM_ROUTING];
self::$_routing = Config::getInstance()->getConfig()[View::NIBIRU_ROUTING];
self::setRoutes(self::$_routing);
self::setCurRoute();
}
/**
@@ -48,11 +50,15 @@ class Router extends Config
/**
* @param mixed $cur_route
*/
private static function _setCurRoute( )
private static function setCurRoute( )
{
if( Controller::getInstance()->getController() != IController::START_CONTROLLER_NAME )
if( self::getCurPage() != IController::START_CONTROLLER_NAME )
{
self::$_cur_route = Controller::getInstance()->getController();
self::$_cur_route = self::getCurPage();
if(self::getAction())
{
self::$_cur_route .= '/' . self::getAction() . '/';
}
}
else
{
@@ -76,7 +82,21 @@ class Router extends Config
self::$_routes = $routes;
}
/**
* @return mixed
*/
protected static function getAction()
{
return self::$_action;
}
/**
* @param mixed $action
*/
private static function setAction( $action )
{
$_REQUEST['_action'] = $action;
}
public function route()
{
@@ -118,7 +138,6 @@ class Router extends Config
*/
private static function setCurPage( )
{
self::_setCurRoute();
if( self::getCurRoute() == null )
{
$uri_parts = explode('/', $_SERVER["REQUEST_URI"]);
@@ -131,6 +150,10 @@ class Router extends Config
else
{
self::$_cur_page = $uri_parts[1];
if(array_key_exists(2, $uri_parts))
{
self::setAction($uri_parts[2]);
}
}
}
}
@@ -138,7 +161,6 @@ class Router extends Config
{
self::$_cur_page = self::getCurRoute();
}
}
/**