REFACTORING: new autoloading functionallity, the modules are now structured for a better overview and module and visibility. Now the modules can also be used for bigger systems, but still are light weight.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Nibiru\Adapter;
|
namespace Nibiru\Module\Users\Interfaces;
|
||||||
/**
|
/**
|
||||||
* @desc this file is for the autoloader to function properly,
|
* @desc this file is for the autoloader to function properly,
|
||||||
* you might as well use it as the primary user interface for your
|
* you might as well use it as the primary user interface for your
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Nibiru\Messages;
|
namespace Nibiru\Module\Users\Traits;
|
||||||
/**
|
/**
|
||||||
* @desc this file is for the autoloader to function properly,
|
* @desc this file is for the autoloader to function properly,
|
||||||
* you might as well use it as the primary user trait for your
|
* you might as well use it as the primary user trait for your
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Nibiru\Module;
|
namespace Nibiru\Module\Users;
|
||||||
/**
|
/**
|
||||||
* @desc this file is for the autoloader to function properly,
|
* @desc this file is for the autoloader to function properly,
|
||||||
* you might as well use it as the primary user class for your
|
* you might as well use it as the primary user class for your
|
||||||
@@ -9,10 +9,10 @@ namespace Nibiru\Module;
|
|||||||
* Date: 28.08.18
|
* Date: 28.08.18
|
||||||
* Time: 11:22
|
* Time: 11:22
|
||||||
*/
|
*/
|
||||||
use Nibiru\Adapter;
|
use Nibiru\Module\Users\Interfaces;
|
||||||
use Nibiru\Messages;
|
use Nibiru\Module\Users\Traits;
|
||||||
|
|
||||||
class Users implements Adapter\Users
|
class Users implements Interfaces\Users
|
||||||
{
|
{
|
||||||
use Messages\Users;
|
use Traits\Users;
|
||||||
}
|
}
|
||||||
@@ -26,9 +26,9 @@ register.text = "PATHTOYOURHTMLTEMPLATE"
|
|||||||
pageurl = "YOURPAGEURLWITHPROTOCOL"
|
pageurl = "YOURPAGEURLWITHPROTOCOL"
|
||||||
navigation = "navigation.json"
|
navigation = "navigation.json"
|
||||||
dbmodel = "/../../application/model/"
|
dbmodel = "/../../application/model/"
|
||||||
module = "/../../application/module/"
|
module = "/../../application/module/[NAME]"
|
||||||
interfaces = "/../../application/interfaces/"
|
interfaces = "/../../application/module/[NAME]/interfaces/"
|
||||||
trait = "/../../application/trait/"
|
traits = "/../../application/module/[NAME]/traits/"
|
||||||
entriesperpage = 4
|
entriesperpage = 4
|
||||||
background.img[] = "public/img/nibiru3.jpg"
|
background.img[] = "public/img/nibiru3.jpg"
|
||||||
smarty.css[] = "public/css/v3/roboto.css"
|
smarty.css[] = "public/css/v3/roboto.css"
|
||||||
|
|||||||
@@ -14,13 +14,16 @@ class Autoloader
|
|||||||
{
|
{
|
||||||
const MY_FILE_NAME = "autoloader.php";
|
const MY_FILE_NAME = "autoloader.php";
|
||||||
const DB_MODEL_FOLDER = "dbmodel";
|
const DB_MODEL_FOLDER = "dbmodel";
|
||||||
const MODULE_FOLDER = "module";
|
const MODULES = [
|
||||||
const INTERFACE_FOLDER = "interfaces";
|
'module',
|
||||||
const TRAIT_FOLDER = "trait";
|
'interfaces',
|
||||||
|
'traits'
|
||||||
|
];
|
||||||
const SETTINGS_SECTION = "AUTOLOADER";
|
const SETTINGS_SECTION = "AUTOLOADER";
|
||||||
const SETTINGS_CLASS_POS = "class.pos";
|
const SETTINGS_CLASS_POS = "class.pos";
|
||||||
const SETTINGS_TRAIT_POS = "trait.pos";
|
const SETTINGS_TRAIT_POS = "trait.pos";
|
||||||
const SETTINGS_IFACE_POS = "iface.pos";
|
const SETTINGS_IFACE_POS = "iface.pos";
|
||||||
|
const REGEX_PATH_NAME = "[NAME]";
|
||||||
|
|
||||||
private static $_filesInFoler = array();
|
private static $_filesInFoler = array();
|
||||||
private static $_instance;
|
private static $_instance;
|
||||||
@@ -61,6 +64,7 @@ class Autoloader
|
|||||||
* @desc will sort the array by a given sort order from the configuration file
|
* @desc will sort the array by a given sort order from the configuration file
|
||||||
* just provided in the AUTOLOADER section.
|
* just provided in the AUTOLOADER section.
|
||||||
* @param array $modules
|
* @param array $modules
|
||||||
|
* @param mixed $section
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function sortOrderModules( array $modules, $section ): array
|
private static function sortOrderModules( array $modules, $section ): array
|
||||||
@@ -163,6 +167,11 @@ class Autoloader
|
|||||||
*/
|
*/
|
||||||
private static function folderContent( string $folderPath ): \RecursiveIteratorIterator
|
private static function folderContent( string $folderPath ): \RecursiveIteratorIterator
|
||||||
{
|
{
|
||||||
|
$folderSettings = Config::getInstance()->getConfig()[self::SETTINGS_SECTION][self::SETTINGS_CLASS_POS];
|
||||||
|
foreach($folderSettings as $moduleFolderName)
|
||||||
|
{
|
||||||
|
$folderPath = str_replace(self::REGEX_PATH_NAME, $moduleFolderName, $folderPath);
|
||||||
|
}
|
||||||
return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( $folderPath ));
|
return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( $folderPath ));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,58 +214,25 @@ class Autoloader
|
|||||||
/**
|
/**
|
||||||
* @desc run check on modules that should provide an interface as well as a trait
|
* @desc run check on modules that should provide an interface as well as a trait
|
||||||
*/
|
*/
|
||||||
$iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::INTERFACE_FOLDER] );
|
foreach(self::MODULES as $module)
|
||||||
foreach ( $iterator as $item )
|
|
||||||
{
|
{
|
||||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
$iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][$module] );
|
||||||
|
foreach ( $iterator as $item )
|
||||||
{
|
{
|
||||||
$interfaces[] = array(
|
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||||
'nfilename' => str_replace('.php', '', $item->getFileName()),
|
{
|
||||||
'filepathname' => $item->getPath() . '/' . $item->getFileName()
|
$moduleFolder[] = array(
|
||||||
);
|
'nfilename' => str_replace('.php', '', $item->getFileName()),
|
||||||
|
'filepathname' => $item->getPath() . '/' . $item->getFileName()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
asort($moduleFolder);
|
||||||
asort($interfaces);
|
$itms = self::sortOrderModules($moduleFolder, self::SETTINGS_IFACE_POS);
|
||||||
$Sinterfaces = self::sortOrderModules($interfaces, self::SETTINGS_IFACE_POS);
|
foreach ($itms as $itm)
|
||||||
foreach ($Sinterfaces as $interface)
|
|
||||||
{
|
|
||||||
self::$_filesInFoler[] = $interface['filepathname'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::TRAIT_FOLDER] );
|
|
||||||
foreach ( $iterator as $item )
|
|
||||||
{
|
|
||||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
|
||||||
{
|
{
|
||||||
$traits[] = array(
|
self::$_filesInFoler[] = $itm['filepathname'];
|
||||||
'nfilename' => str_replace('.php', '', $item->getFileName()),
|
|
||||||
'filepathname' => $item->getPath() . '/' . $item->getFileName()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asort($traits);
|
|
||||||
$Straits = self::sortOrderModules($traits, self::SETTINGS_TRAIT_POS);
|
|
||||||
foreach($Straits as $trait)
|
|
||||||
{
|
|
||||||
self::$_filesInFoler[] = $trait['filepathname'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::MODULE_FOLDER] );
|
|
||||||
foreach ( $iterator as $item )
|
|
||||||
{
|
|
||||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
|
||||||
{
|
|
||||||
$modules[] = array(
|
|
||||||
'nfilename' => str_replace('.php', '', $item->getFileName()),
|
|
||||||
'filepathname' => $item->getPath() . '/' . $item->getFileName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
asort($modules);
|
|
||||||
$Smodules = self::sortOrderModules($modules, self::SETTINGS_CLASS_POS);
|
|
||||||
foreach ($Smodules as $module)
|
|
||||||
{
|
|
||||||
self::$_filesInFoler[] = $module['filepathname'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ interface IDb
|
|||||||
* @desc inserts a rowset into the table, by the given nextInsertIndex return
|
* @desc inserts a rowset into the table, by the given nextInsertIndex return
|
||||||
* value for the table
|
* value for the table
|
||||||
* @param bool $id
|
* @param bool $id
|
||||||
|
* @param array $rowset
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function insertRowsetById( $rowset = array(), $id = false );
|
public function insertRowsetById( $rowset = array(), $id = false );
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ interface IForm
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc loads the current Form element to the form
|
* @desc loads the current Form element to the form
|
||||||
* @param $element
|
* @param $attributes
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function loadElement( $attributes );
|
public function loadElement( $attributes );
|
||||||
|
|||||||
Reference in New Issue
Block a user