mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-10 17:28:40 +00:00
general fixes
This commit is contained in:
parent
121e6b4486
commit
189d37580d
|
|
@ -40,10 +40,10 @@ final class Dispatcher implements DispatcherInterface
|
||||||
*
|
*
|
||||||
* Set in the module manager on module initialization.
|
* Set in the module manager on module initialization.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<string, object>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private array $controllers = [];
|
public array $controllers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
|
@ -127,19 +127,4 @@ final class Dispatcher implements DispatcherInterface
|
||||||
|
|
||||||
return $this->controllers[$controller];
|
return $this->controllers[$controller];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set controller by alias.
|
|
||||||
*
|
|
||||||
* @param object $controller Controller
|
|
||||||
* @param string $name Controller string
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function set(object $controller, string $name) : void
|
|
||||||
{
|
|
||||||
$this->controllers[$name] = $controller;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -674,7 +674,7 @@ final class ModuleManager
|
||||||
$ctrl = $this->get($module, $ctlName);
|
$ctrl = $this->get($module, $ctlName);
|
||||||
|
|
||||||
if ($this->app->dispatcher !== null) {
|
if ($this->app->dispatcher !== null) {
|
||||||
$this->app->dispatcher->set($ctrl, $name);
|
$this->app->dispatcher->controllers[$name] = $ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle providing->receiving
|
// Handle providing->receiving
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ final class SocketRouter implements RouterInterface
|
||||||
/**
|
/**
|
||||||
* Routes.
|
* Routes.
|
||||||
*
|
*
|
||||||
* @var array<string, array>
|
* @var array<string, array<int, array{dest:string, verb:int, csrf?:bool, active?:bool, permission:array{module:string, type:int, category:int}, validation?:array{}, pattern?:string}>>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private array $routes = [];
|
private array $routes = [];
|
||||||
|
|
@ -40,15 +40,19 @@ final class SocketRouter implements RouterInterface
|
||||||
* Files need to return a php array of the following structure (see PermissionHandlingTrait):
|
* Files need to return a php array of the following structure (see PermissionHandlingTrait):
|
||||||
* return [
|
* return [
|
||||||
* '{REGEX_PATH}' => [
|
* '{REGEX_PATH}' => [
|
||||||
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
* [
|
||||||
* 'permission' => [ // optional
|
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
||||||
* 'module' => '{NAME}',
|
* 'verb' => RouteVerb::{VERB},
|
||||||
* 'type' => PermissionType::{TYPE},
|
* 'csrf' => true,
|
||||||
* 'category' => PermissionCategory::{STATE},
|
* 'permission' => [ // optional
|
||||||
|
* 'module' => '{NAME}',
|
||||||
|
* 'type' => PermissionType::{TYPE},
|
||||||
|
* 'category' => PermissionCategory::{STATE},
|
||||||
|
* ],
|
||||||
* ],
|
* ],
|
||||||
* // define different destination for different verb
|
* // define different destination for different verb
|
||||||
* ],
|
* ]
|
||||||
* // define another regex path, destination, permission here
|
* // define another regex path here
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* @param string $path Route file path
|
* @param string $path Route file path
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ final class WebRouter implements RouterInterface
|
||||||
/**
|
/**
|
||||||
* Routes.
|
* Routes.
|
||||||
*
|
*
|
||||||
* @var array<string, array>
|
* @var array<string, array<int, array{dest:string, verb:int, csrf?:bool, active?:bool, permission:array{module:string, type:int, category:int}, validation?:array{}, pattern?:string}>>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private array $routes = [];
|
private array $routes = [];
|
||||||
|
|
@ -51,17 +51,19 @@ final class WebRouter implements RouterInterface
|
||||||
* Files need to return a php array of the following structure (see PermissionHandlingTrait):
|
* Files need to return a php array of the following structure (see PermissionHandlingTrait):
|
||||||
* return [
|
* return [
|
||||||
* '{REGEX_PATH}' => [
|
* '{REGEX_PATH}' => [
|
||||||
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
* [
|
||||||
* 'verb' => RouteVerb::{VERB},
|
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
||||||
* 'csrf' => true,
|
* 'verb' => RouteVerb::{VERB},
|
||||||
* 'permission' => [ // optional
|
* 'csrf' => true,
|
||||||
* 'module' => '{NAME}',
|
* 'permission' => [ // optional
|
||||||
* 'type' => PermissionType::{TYPE},
|
* 'module' => '{NAME}',
|
||||||
* 'category' => PermissionCategory::{STATE},
|
* 'type' => PermissionType::{TYPE},
|
||||||
|
* 'category' => PermissionCategory::{STATE},
|
||||||
|
* ],
|
||||||
* ],
|
* ],
|
||||||
* // define different destination for different verb
|
* // define different destination for different verb
|
||||||
* ],
|
* ]
|
||||||
* // define another regex path, destination, permission here
|
* // define another regex path here
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* @param string $path Route file path
|
* @param string $path Route file path
|
||||||
|
|
@ -113,6 +115,7 @@ final class WebRouter implements RouterInterface
|
||||||
'dest' => $destination,
|
'dest' => $destination,
|
||||||
'verb' => $verb,
|
'verb' => $verb,
|
||||||
'csrf' => $csrf,
|
'csrf' => $csrf,
|
||||||
|
'active' => true,
|
||||||
'validation' => empty($validation) ? null : $validation,
|
'validation' => empty($validation) ? null : $validation,
|
||||||
'pattern' => empty($dataPattern) ? null : $dataPattern,
|
'pattern' => empty($dataPattern) ? null : $dataPattern,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,11 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
#[\PHPUnit\Framework\Attributes\TestDox('A route can be added and dispatched')]
|
#[\PHPUnit\Framework\Attributes\TestDox('A route can be added and dispatched')]
|
||||||
public function testControllerInputOutput() : void
|
public function testControllerInputOutput() : void
|
||||||
{
|
{
|
||||||
$this->app->dispatcher->set(new class() extends ModuleAbstract {
|
$this->app->dispatcher->controllers['test'] = new class() extends ModuleAbstract {
|
||||||
public string $name = 'test';
|
public string $name = 'test';
|
||||||
|
|
||||||
public function testFunction() { return $this->name; }
|
public function testFunction() { return $this->name; }
|
||||||
}, 'test');
|
};
|
||||||
|
|
||||||
$localization = new Localization();
|
$localization = new Localization();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user