Remove \Basic class from all other Class extensions

If not created Logger class will be auto created in \DB\IO
Recommended to run a CoreLibs\Debug\Logging([...]); and use this class
for all ACL\Login, Admin\Backend, DB\IO, Output\Form\Generate calls.
Last parameter after DB CONFIG is the log parameter

Session create has been moved to a new Create\Session class from the
\Basic class and MUST be started before using ACL\Login. Currently
ACL\Login will fallback and start it if no session is yet started.

See the Readme.md file for which classes use _SESSION data

In future the _SESSION settings should be moved to some wrapper class
for this so we can unit test sessions

Only Output\Form\Generate class call has the new changed with the second
parameter no longer beeing the table width setting but the class
setting.
But as this is a semi retired class and only used for edit_base this is
not 100% breaking.
All other classes can be used as is and have internal fallback to run as
before.
Deprecation messages will be added later.
This commit is contained in:
Clemens Schwaighofer
2022-01-18 10:51:13 +09:00
parent 1bd45d8a8a
commit ad39a5b21f
45 changed files with 991 additions and 284 deletions

View File

@@ -0,0 +1,74 @@
<?php
/*
* start a php sesseion
* name can be given via startSession parameter
* if not set tries to read $SET_SESSION_NAME from global
* if this is not set tries to read SET_SESSION_NAME constant
*/
declare(strict_types=1);
namespace CoreLibs\Create;
class Session
{
/**
* init a session
*/
public function __construct()
{
}
/**
* Undocumented function
*
* @param string|null $session_name
* @return string|bool
*/
public static function startSession(?string $session_name = null)
{
// initial the session if there is no session running already
if (!session_id()) {
$session_name = $session_name ?? $GLOBALS['SET_SESSION_NAME'] ?? '';
// check if we have an external session name given, else skip this step
if (
empty($session_name) &&
defined('SET_SESSION_NAME') &&
!empty(SET_SESSION_NAME)
) {
// set the session name for possible later check
$session_name = SET_SESSION_NAME;
}
// if set, set special session name
if (!empty($session_name)) {
session_name($session_name);
}
// start session
session_start();
}
return self::getSessionId();
}
/**
* Undocumented function
*
* @return string|bool
*/
public static function getSessionId()
{
return session_id();
}
/**
* Undocumented function
*
* @return string|bool
*/
public static function getSessionName()
{
return session_name();
}
}
// __END__