mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-10 01:08: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.
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, object>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $controllers = [];
|
||||
public array $controllers = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -127,19 +127,4 @@ final class Dispatcher implements DispatcherInterface
|
|||
|
||||
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);
|
||||
|
||||
if ($this->app->dispatcher !== null) {
|
||||
$this->app->dispatcher->set($ctrl, $name);
|
||||
$this->app->dispatcher->controllers[$name] = $ctrl;
|
||||
}
|
||||
|
||||
// Handle providing->receiving
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ final class SocketRouter implements RouterInterface
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
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):
|
||||
* return [
|
||||
* '{REGEX_PATH}' => [
|
||||
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
||||
* 'permission' => [ // optional
|
||||
* 'module' => '{NAME}',
|
||||
* 'type' => PermissionType::{TYPE},
|
||||
* 'category' => PermissionCategory::{STATE},
|
||||
* [
|
||||
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
||||
* 'verb' => RouteVerb::{VERB},
|
||||
* 'csrf' => true,
|
||||
* 'permission' => [ // optional
|
||||
* 'module' => '{NAME}',
|
||||
* 'type' => PermissionType::{TYPE},
|
||||
* 'category' => PermissionCategory::{STATE},
|
||||
* ],
|
||||
* ],
|
||||
* // define different destination for different verb
|
||||
* ],
|
||||
* // define another regex path, destination, permission here
|
||||
* ]
|
||||
* // define another regex path here
|
||||
* ];
|
||||
*
|
||||
* @param string $path Route file path
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ final class WebRouter implements RouterInterface
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
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):
|
||||
* return [
|
||||
* '{REGEX_PATH}' => [
|
||||
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
||||
* 'verb' => RouteVerb::{VERB},
|
||||
* 'csrf' => true,
|
||||
* 'permission' => [ // optional
|
||||
* 'module' => '{NAME}',
|
||||
* 'type' => PermissionType::{TYPE},
|
||||
* 'category' => PermissionCategory::{STATE},
|
||||
* [
|
||||
* 'dest' => '{DESTINATION_NAMESPACE:method}', // use :: for static functions
|
||||
* 'verb' => RouteVerb::{VERB},
|
||||
* 'csrf' => true,
|
||||
* 'permission' => [ // optional
|
||||
* 'module' => '{NAME}',
|
||||
* 'type' => PermissionType::{TYPE},
|
||||
* 'category' => PermissionCategory::{STATE},
|
||||
* ],
|
||||
* ],
|
||||
* // define different destination for different verb
|
||||
* ],
|
||||
* // define another regex path, destination, permission here
|
||||
* ]
|
||||
* // define another regex path here
|
||||
* ];
|
||||
*
|
||||
* @param string $path Route file path
|
||||
|
|
@ -113,6 +115,7 @@ final class WebRouter implements RouterInterface
|
|||
'dest' => $destination,
|
||||
'verb' => $verb,
|
||||
'csrf' => $csrf,
|
||||
'active' => true,
|
||||
'validation' => empty($validation) ? null : $validation,
|
||||
'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')]
|
||||
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 function testFunction() { return $this->name; }
|
||||
}, 'test');
|
||||
};
|
||||
|
||||
$localization = new Localization();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user