diff --git a/README.md b/README.md
index bb8d7712..c1f38b5d 100644
--- a/README.md
+++ b/README.md
@@ -13,17 +13,17 @@ Documentation is available at: https://docs.dotkernel.org/api-documentation/
## Badges

-
+
[](https://github.com/dotkernel/api/issues)
[](https://github.com/dotkernel/api/network)
[](https://github.com/dotkernel/api/stargazers)
-[](https://github.com/dotkernel/api/blob/5.0/LICENSE.md)
+[](https://github.com/dotkernel/api/blob/6.0/LICENSE.md)
-[](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml)
+[](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml)
[](https://codecov.io/gh/dotkernel/api)
-[](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml)
-[](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml)
+[](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml)
+[](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml)
## Getting Started
@@ -77,7 +77,7 @@ composer development-status
* run the database migrations by using the following command:
```shell
-php vendor/bin/doctrine-migrations migrate
+php ./vendor/bin/doctrine-migrations migrate
```
This command will prompt you to confirm that you want to run it:
@@ -93,7 +93,7 @@ Hit `Enter` to confirm the operation.
To list all the fixtures, run:
```shell
-php bin/doctrine fixtures:list
+php ./bin/doctrine fixtures:list
```
This will output all the fixtures in the order of execution.
@@ -101,13 +101,13 @@ This will output all the fixtures in the order of execution.
To execute all fixtures, run:
```shell
-php bin/doctrine fixtures:execute
+php ./bin/doctrine fixtures:execute
```
To execute a specific fixture, run:
```shell
-php bin/doctrine fixtures:execute --class=FixtureClassName
+php ./bin/doctrine fixtures:execute --class=FixtureClassName
```
More details on how fixtures work can be found here: https://github.com/dotkernel/dot-data-fixtures#creating-fixtures
diff --git a/composer.json b/composer.json
index 2c093e32..0472dba8 100644
--- a/composer.json
+++ b/composer.json
@@ -57,8 +57,9 @@
"dotkernel/dot-dependency-injection": "^1.2",
"dotkernel/dot-errorhandler": "^4.0.0",
"dotkernel/dot-mail": "^5.3.0",
- "dotkernel/dot-response-header": "^3.4.1",
- "dotkernel/dot-router": "^1.0.4",
+ "dotkernel/dot-response-header": "^3.5.0",
+ "dotkernel/dot-router": "^1.0.5",
+ "laminas/laminas-authentication": "^2.18",
"laminas/laminas-component-installer": "^3.5.0",
"laminas/laminas-config-aggregator": "^1.18.0",
"laminas/laminas-hydrator": "^4.16.0",
@@ -70,21 +71,21 @@
"mezzio/mezzio-authorization-rbac": "^1.8.0",
"mezzio/mezzio-cors": "^1.13.0",
"mezzio/mezzio-fastroute": "^3.12.0",
- "mezzio/mezzio-hal": "^2.10",
+ "mezzio/mezzio-hal": "^2.10.1",
"mezzio/mezzio-problem-details": "^1.15.0",
"mezzio/mezzio-twigrenderer": "^2.17.0",
"ramsey/uuid-doctrine": "^2.1.0",
"roave/psr-container-doctrine": "^5.2.2",
"symfony/filesystem": "^7.2.0",
- "zircote/swagger-php": "^5.0.6"
+ "zircote/swagger-php": "^5.0.7"
},
"require-dev": {
"laminas/laminas-coding-standard": "^3.0.1",
"laminas/laminas-development-mode": "^3.13.0",
"mezzio/mezzio-tooling": "^2.10.1",
- "phpstan/phpstan": "^2.1.7",
+ "phpstan/phpstan": "^2.1.11",
"phpstan/phpstan-doctrine": "^2.0.2",
- "phpstan/phpstan-phpunit": "^2.0.4",
+ "phpstan/phpstan-phpunit": "^2.0.6",
"phpunit/phpunit": "^10.5.45",
"roave/security-advisories": "dev-latest",
"symfony/var-dumper": "^7.2.3"
@@ -98,6 +99,7 @@
"Core\\Admin\\": "src/Core/src/Admin/src/",
"Core\\App\\": "src/Core/src/App/src/",
"Core\\Security\\": "src/Core/src/Security/src/",
+ "Core\\Setting\\": "src/Core/src/Setting/src/",
"Core\\User\\": "src/Core/src/User/src/"
}
},
diff --git a/config/autoload/authorization.global.php b/config/autoload/authorization.global.php
index 0200936f..06945bf0 100644
--- a/config/autoload/authorization.global.php
+++ b/config/autoload/authorization.global.php
@@ -2,8 +2,8 @@
declare(strict_types=1);
-use Core\Admin\Entity\AdminRole;
-use Core\User\Entity\UserRole;
+use Core\Admin\Enum\AdminRoleEnum;
+use Core\User\Enum\UserRoleEnum;
return [
/**
@@ -19,17 +19,17 @@
*/
'mezzio-authorization-rbac' => [
'roles' => [
- AdminRole::ROLE_SUPERUSER => [],
- AdminRole::ROLE_ADMIN => [
- AdminRole::ROLE_SUPERUSER,
+ AdminRoleEnum::Superuser->value => [],
+ AdminRoleEnum::Admin->value => [
+ AdminRoleEnum::Superuser->value,
],
- UserRole::ROLE_GUEST => [
- UserRole::ROLE_USER,
+ UserRoleEnum::Guest->value => [
+ UserRoleEnum::User->value,
],
],
'permissions' => [
- AdminRole::ROLE_SUPERUSER => [],
- AdminRole::ROLE_ADMIN => [
+ AdminRoleEnum::Superuser->value => [],
+ AdminRoleEnum::Admin->value => [
'admin::list-admin',
'admin::create-admin',
'admin::delete-admin',
@@ -54,7 +54,7 @@
'app::create-error-report',
'app::view-index',
],
- UserRole::ROLE_USER => [
+ UserRoleEnum::User->value => [
'user::delete-account',
'user::view-account',
'user::update-account',
@@ -62,7 +62,7 @@
'user::view-account-avatar',
'user::create-account-avatar',
],
- UserRole::ROLE_GUEST => [
+ UserRoleEnum::Guest->value => [
'app::create-error-report',
'app::view-index',
'user::activate-account',
diff --git a/config/autoload/cli.global.php b/config/autoload/cli.global.php
index 16a9b9ca..1c91bd3c 100644
--- a/config/autoload/cli.global.php
+++ b/config/autoload/cli.global.php
@@ -3,9 +3,8 @@
declare(strict_types=1);
use Api\Admin\Command\AdminCreateCommand;
-use Api\App\Command\RouteListCommand;
use Api\App\Command\TokenGenerateCommand;
-use Dot\Cli\Command\DemoCommand;
+use Core\App\Command\RouteListCommand;
use Dot\Cli\FileLockerInterface;
return [
@@ -13,7 +12,6 @@
'version' => '1.0.0',
'name' => 'Dotkernel CLI',
'commands' => [
- DemoCommand::getDefaultName() => DemoCommand::class,
RouteListCommand::getDefaultName() => RouteListCommand::class,
AdminCreateCommand::getDefaultName() => AdminCreateCommand::class,
TokenGenerateCommand::getDefaultName() => TokenGenerateCommand::class,
diff --git a/config/autoload/content-negotiation.global.php b/config/autoload/content-negotiation.global.php
index b464f768..59a2d6dc 100644
--- a/config/autoload/content-negotiation.global.php
+++ b/config/autoload/content-negotiation.global.php
@@ -4,7 +4,7 @@
return [
'content-negotiation' => [
- 'default' => [ // default to any route if not configured above
+ 'default' => [ // default to any route if not configured above
'Accept' => [ // the Accept is what format the server can send back
'application/json',
'application/hal+json',
@@ -14,11 +14,11 @@
'application/hal+json',
],
],
- 'your.route.name' => [
+ 'your.route.name' => [
'Accept' => [],
'Content-Type' => [],
],
- 'user.avatar.create' => [
+ 'user::create-account-avatar' => [
'Accept' => [
'application/json',
'application/hal+json',
@@ -27,7 +27,7 @@
'multipart/form-data',
],
],
- 'user.my-avatar.create' => [
+ 'user::create-user-avatar' => [
'Accept' => [
'application/json',
'application/hal+json',
diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist
index 59221147..ae3ea737 100644
--- a/config/autoload/local.php.dist
+++ b/config/autoload/local.php.dist
@@ -7,7 +7,7 @@ $baseUrl = 'http://localhost:8080';
$databases = [
'default' => [
'host' => 'localhost',
- 'dbname' => '',
+ 'dbname' => 'dotkernel',
'user' => '',
'password' => '',
'port' => 3306,
@@ -15,12 +15,13 @@ $databases = [
'charset' => 'utf8mb4',
'collate' => 'utf8mb4_general_ci',
],
- // you can add more database connections into this array
+ // you can add more database connections to this array
];
return [
'application' => [
'name' => 'Dotkernel API',
+ 'version' => 6,
'url' => $baseUrl,
'versioning' => [
'documentation_url' => 'https://docs.dotkernel.org/api-documentation/v5/core-features/versioning',
@@ -28,14 +29,14 @@ return [
],
'authentication' => [
'private_key' => [
- 'key_or_path' => getcwd() . '/data/oauth/private.key',
+ 'key_or_path' => realpath(__DIR__ . '/../../data/oauth/private.key'),
'key_permissions_check' => false,
],
'public_key' => [
- 'key_or_path' => getcwd() . '/data/oauth/public.key',
+ 'key_or_path' => realpath(__DIR__ . '/../../data/oauth/public.key'),
'key_permissions_check' => false,
],
- 'encryption_key' => require getcwd() . '/data/oauth/encryption.key',
+ 'encryption_key' => require realpath(__DIR__ . '/../../data/oauth/encryption.key'),
'access_token_expire' => 'P1D',
'refresh_token_expire' => 'P1M',
'auth_code_expire' => 'PT10M',
diff --git a/config/config.php b/config/config.php
index ebd973a7..2634df46 100644
--- a/config/config.php
+++ b/config/config.php
@@ -10,6 +10,15 @@
];
$aggregator = new Laminas\ConfigAggregator\ConfigAggregator([
+ // Laminas packages
+ Laminas\Diactoros\ConfigProvider::class,
+ Laminas\InputFilter\ConfigProvider::class,
+ Laminas\Filter\ConfigProvider::class,
+ Laminas\HttpHandlerRunner\ConfigProvider::class,
+ Laminas\Hydrator\ConfigProvider::class,
+ Laminas\Validator\ConfigProvider::class,
+
+ // Mezzio packages
Mezzio\Authorization\ConfigProvider::class,
Mezzio\Authorization\Acl\ConfigProvider::class,
Mezzio\Authorization\Rbac\ConfigProvider::class,
@@ -20,14 +29,6 @@
Mezzio\ProblemDetails\ConfigProvider::class,
Mezzio\Router\FastRouteRouter\ConfigProvider::class,
Mezzio\Twig\ConfigProvider::class,
- Laminas\Diactoros\ConfigProvider::class,
- Laminas\InputFilter\ConfigProvider::class,
- Laminas\Filter\ConfigProvider::class,
- Laminas\HttpHandlerRunner\ConfigProvider::class,
- Laminas\Hydrator\ConfigProvider::class,
- Laminas\Validator\ConfigProvider::class,
- // Include cache configuration
- new Laminas\ConfigAggregator\ArrayProvider($cacheConfig),
Mezzio\Helper\ConfigProvider::class,
Mezzio\ConfigProvider::class,
Mezzio\Router\ConfigProvider::class,
@@ -37,6 +38,9 @@ class_exists(Mezzio\Tooling\ConfigProvider::class)
return [];
},
+ // Include cache configuration
+ new Laminas\ConfigAggregator\ArrayProvider($cacheConfig),
+
// DK packages
Dot\Cli\ConfigProvider::class,
Dot\Log\ConfigProvider::class,
@@ -48,15 +52,16 @@ class_exists(Mezzio\Tooling\ConfigProvider::class)
Dot\Cache\ConfigProvider::class,
Dot\Router\ConfigProvider::class,
- // Default App module config
- Core\Admin\ConfigProvider::class,
- Core\App\ConfigProvider::class,
- Core\Security\ConfigProvider::class,
- Core\User\ConfigProvider::class,
+ // Dotkernel modules
Api\Admin\ConfigProvider::class,
Api\App\ConfigProvider::class,
Api\Security\ConfigProvider::class,
Api\User\ConfigProvider::class,
+ Core\Admin\ConfigProvider::class,
+ Core\App\ConfigProvider::class,
+ Core\Security\ConfigProvider::class,
+ Core\Setting\ConfigProvider::class,
+ Core\User\ConfigProvider::class,
// Load application config in a pre-defined order in such a way that local settings
// overwrite global settings. (Loaded as first to last):
@@ -64,6 +69,7 @@ class_exists(Mezzio\Tooling\ConfigProvider::class)
// - `*.global.php`
// - `local.php`
// - `*.local.php`
+ // - `local.test.php`
new Laminas\ConfigAggregator\PhpFileProvider(
realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local,{,*.}test}.php'
),
diff --git a/documentation/Dotkernel_API.postman_collection.json b/documentation/Dotkernel_API.postman_collection.json
index 094dd83e..26901446 100644
--- a/documentation/Dotkernel_API.postman_collection.json
+++ b/documentation/Dotkernel_API.postman_collection.json
@@ -1,10 +1,10 @@
{
"info": {
- "_postman_id": "aae441d2-e81b-462a-97c1-4541564a9894",
+ "_postman_id": "f837d47b-cc12-4897-8b1a-ecd26b4bbe44",
"name": "Dotkernel_API",
"description": "Dotkernel API documentation.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
- "_exporter_id": "13971428"
+ "_exporter_id": "3494496"
},
"item": [
{
@@ -61,7 +61,7 @@
"response": []
}
],
- "description": "Admins manager their accounts."
+ "description": "Admins manage their own account."
},
{
"name": "Admin",
@@ -73,7 +73,7 @@
"header": [],
"body": {
"mode": "raw",
- "raw": "{\r\n \"identity\": \"{{$randomUserName}}\",\r\n \"password\": \"dotkernel\",\r\n \"passwordConfirm\": \"dotkernel\",\r\n \"firstName\": \"{{$randomFirstName}}\",\r\n \"lastName\": \"{{$randomLastName}}\",\r\n \"roles\": [\r\n {\r\n \"uuid\": \"{{$randomUUID}}\"\r\n }\r\n ]\r\n}",
+ "raw": "{\r\n \"identity\": \"{{$randomUserName}}\",\r\n \"password\": \"dotkernel\",\r\n \"passwordConfirm\": \"dotkernel\",\r\n \"firstName\": \"{{$randomFirstName}}\",\r\n \"lastName\": \"{{$randomLastName}}\",\r\n \"status\": \"active\",\r\n \"roles\": [\r\n {\r\n \"uuid\": \"{{$randomUUID}}\"\r\n }\r\n ]\r\n}",
"options": {
"raw": {
"language": "json"
@@ -113,7 +113,7 @@
"response": []
},
{
- "name": "List admin",
+ "name": "List admins",
"request": {
"method": "GET",
"header": [],
@@ -137,7 +137,7 @@
"disabled": true
},
{
- "key": "order",
+ "key": "sort",
"value": "admin.created",
"disabled": true
},
@@ -145,6 +145,21 @@
"key": "dir",
"value": "desc",
"disabled": true
+ },
+ {
+ "key": "filters[identity]",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "filters[status]",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "filters[role]",
+ "value": "",
+ "disabled": true
}
]
},
@@ -159,7 +174,7 @@
"header": [],
"body": {
"mode": "raw",
- "raw": "{\r\n \"password\": \"dotkernel\",\r\n \"passwordConfirm\": \"dotkernel\",\r\n \"firstName\": \"{{$randomFirstName}}\",\r\n \"lastName\": \"{{$randomLastName}}\",\r\n \"roles\": [\r\n {\r\n \"uuid\": \"{{$randomUUID}}\"\r\n }\r\n ]\r\n}",
+ "raw": "{\r\n \"password\": \"dotkernel\",\r\n \"passwordConfirm\": \"dotkernel\",\r\n \"firstName\": \"{{$randomFirstName}}\",\r\n \"lastName\": \"{{$randomLastName}}\",\r\n \"roles\": [\r\n {\r\n \"uuid\": \"{{$randomUUID}}\"\r\n }\r\n ],\r\n \"status\": \"active\"\r\n}",
"options": {
"raw": {
"language": "json"
@@ -167,13 +182,13 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/admin/{{$randomUUID}}",
+ "raw": "{{APPLICATION_URL}}/admin/abd444ed-cc65-41e7-96c7-2391a9103f15",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
"admin",
- "{{$randomUUID}}"
+ "abd444ed-cc65-41e7-96c7-2391a9103f15"
]
},
"description": "Admin updates admin account.\n\nReplace random UUID in URL with a valid user UUID."
@@ -223,7 +238,8 @@
},
"response": []
}
- ]
+ ],
+ "description": "Admins manage other admin accounts."
},
{
"name": "Role",
@@ -254,7 +270,7 @@
"disabled": true
},
{
- "key": "order",
+ "key": "sort",
"value": "role.created",
"disabled": true
},
@@ -262,6 +278,11 @@
"key": "dir",
"value": "desc",
"disabled": true
+ },
+ {
+ "key": "filters[name]",
+ "value": "",
+ "disabled": true
}
]
},
@@ -289,7 +310,8 @@
},
"response": []
}
- ]
+ ],
+ "description": "Admins manage admin roles."
},
{
"name": "Security",
@@ -323,7 +345,7 @@
"header": [],
"body": {
"mode": "raw",
- "raw": "{\r\n \"grant_type\": \"password\",\r\n \"client_id\": \"admin\",\r\n \"client_secret\": \"admin\",\r\n \"scope\": \"api\",\r\n \"username\": \"admin\",\r\n \"password\": \"dotkernel\"\r\n}",
+ "raw": "{\r\n \"grant_type\": \"password\",\r\n \"client_id\": \"admin\",\r\n \"client_secret\": \"admin\",\r\n \"scope\": \"api\",\r\n \"username\": \"admin\",\r\n \"password\": \"dotadmin\"\r\n}",
"options": {
"raw": {
"language": "json"
@@ -395,6 +417,7 @@
"response": []
}
],
+ "description": "Admins re/generate their access token.",
"auth": {
"type": "noauth"
},
@@ -428,6 +451,7 @@
]
}
],
+ "description": "Admin module documentation.",
"event": [
{
"listen": "prerequest",
@@ -528,7 +552,8 @@
},
"response": []
}
- ]
+ ],
+ "description": "Users manage their own avatar."
},
{
"name": "Activate my account",
@@ -539,11 +564,12 @@
"method": "PATCH",
"header": [],
"url": {
- "raw": "{{APPLICATION_URL}}/account/activate/{{RANDOM_HASH}}",
+ "raw": "{{APPLICATION_URL}}/user/account/activate/{{RANDOM_HASH}}",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
+ "user",
"account",
"activate",
"{{RANDOM_HASH}}"
@@ -571,11 +597,12 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/account/activate",
+ "raw": "{{APPLICATION_URL}}/user/account/activate",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
+ "user",
"account",
"activate"
]
@@ -621,11 +648,12 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/account/reset-password/{{RANDOM_HASH}}",
+ "raw": "{{APPLICATION_URL}}/user/account/reset-password/{{RANDOM_HASH}}",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
+ "user",
"account",
"reset-password",
"{{RANDOM_HASH}}"
@@ -653,11 +681,12 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/account/recover",
+ "raw": "{{APPLICATION_URL}}/user/account/recover",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
+ "user",
"account",
"recover"
]
@@ -675,7 +704,8 @@
"exec": [
""
],
- "type": "text/javascript"
+ "type": "text/javascript",
+ "packages": {}
}
}
],
@@ -695,13 +725,13 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/account/register",
+ "raw": "{{APPLICATION_URL}}/user/account",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
- "account",
- "register"
+ "user",
+ "account"
]
},
"description": "Guest registers new user account."
@@ -726,11 +756,12 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/account/reset-password",
+ "raw": "{{APPLICATION_URL}}/user/account/reset-password",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
+ "user",
"account",
"reset-password"
]
@@ -757,11 +788,12 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/account/reset-password",
+ "raw": "{{APPLICATION_URL}}/user/account/reset-password",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
+ "user",
"account",
"reset-password"
]
@@ -779,11 +811,12 @@
"method": "GET",
"header": [],
"url": {
- "raw": "{{APPLICATION_URL}}/account/reset-password/{{RANDOM_HASH}}",
+ "raw": "{{APPLICATION_URL}}/user/account/reset-password/{{RANDOM_HASH}}",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
+ "user",
"account",
"reset-password",
"{{RANDOM_HASH}}"
@@ -841,7 +874,7 @@
"response": []
}
],
- "description": "Authenticated users manage their accounts."
+ "description": "Users manage their own account."
},
{
"name": "Role",
@@ -872,7 +905,7 @@
"disabled": true
},
{
- "key": "order",
+ "key": "sort",
"value": "role.created",
"disabled": true
},
@@ -880,6 +913,11 @@
"key": "dir",
"value": "desc",
"disabled": true
+ },
+ {
+ "key": "filters[name]",
+ "value": "",
+ "disabled": true
}
]
},
@@ -907,7 +945,8 @@
},
"response": []
}
- ]
+ ],
+ "description": "Admins manage user roles."
},
{
"name": "Security",
@@ -921,7 +960,8 @@
"exec": [
""
],
- "type": "text/javascript"
+ "type": "text/javascript",
+ "packages": {}
}
}
],
@@ -938,13 +978,13 @@
}
},
"url": {
- "raw": "{{APPLICATION_URL}}/security/generate-token",
+ "raw": "{{APPLICATION_URL}}/security/token",
"host": [
"{{APPLICATION_URL}}"
],
"path": [
"security",
- "generate-token"
+ "token"
]
},
"description": "Generate OAuth2 Bearer token for identity with regular user privileges."
@@ -992,7 +1032,7 @@
"response": []
}
],
- "description": "Generate/Refresh OAuth2 Bearer token with regular user privileges.",
+ "description": "Users re/generate their access token.",
"auth": {
"type": "noauth"
},
@@ -1101,7 +1141,8 @@
},
"response": []
}
- ]
+ ],
+ "description": "Admins manage user avatars."
},
{
"name": "Activate user",
@@ -1199,7 +1240,7 @@
"response": []
},
{
- "name": "List user",
+ "name": "List users",
"request": {
"method": "GET",
"header": [],
@@ -1225,7 +1266,7 @@
"disabled": true
},
{
- "key": "order",
+ "key": "sort",
"value": "user.created",
"description": "order results by this field",
"disabled": true
@@ -1235,6 +1276,26 @@
"value": "desc",
"description": "order results direction",
"disabled": true
+ },
+ {
+ "key": "filters[identity]",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "filters[email]",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "filters[status]",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "filters[role]",
+ "value": "",
+ "disabled": true
}
]
},
@@ -1289,9 +1350,11 @@
},
"response": []
}
- ]
+ ],
+ "description": "Admins manage user accounts."
}
],
+ "description": "User module documentation.",
"event": [
{
"listen": "prerequest",
@@ -1408,4 +1471,4 @@
"value": "597155ec70defb9f969c9beaf609814933db53cbcb8b9be6db5e0bf7e051e1e4"
}
]
-}
\ No newline at end of file
+}
diff --git a/documentation/Dotkernel_API.postman_environment.json b/documentation/Dotkernel_API.postman_environment.json
index ff51409e..d1bc2362 100644
--- a/documentation/Dotkernel_API.postman_environment.json
+++ b/documentation/Dotkernel_API.postman_environment.json
@@ -1,14 +1,26 @@
{
- "id": "3ee44887-32cc-4427-891a-4336eff67d80",
+ "id": "c4763296-be10-4ff4-82c2-583c932c76c4",
"name": "Dotkernel_API",
"values": [
{
"key": "APPLICATION_URL",
- "value": "http://localhost:8080",
+ "value": "http://api.dotkernel.localhost",
+ "enabled": true
+ },
+ {
+ "key": "ACCESS_TOKEN",
+ "value": "",
+ "type": "any",
+ "enabled": true
+ },
+ {
+ "key": "REFRESH_TOKEN",
+ "value": "",
+ "type": "any",
"enabled": true
}
],
"_postman_variable_scope": "environment",
- "_postman_exported_at": "2021-05-14T06:40:40.313Z",
- "_postman_exported_using": "Postman/8.4.0"
-}
\ No newline at end of file
+ "_postman_exported_at": "2025-04-10T11:59:16.370Z",
+ "_postman_exported_using": "Postman/11.40.1"
+}
diff --git a/phpcs.xml b/phpcs.xml
index c4307090..f2575524 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -18,11 +18,10 @@
src
test
- src/Core/src/App/src/Migration/*
-
+ src/Core/src/App/src/Migration/*
diff --git a/phpstan.neon b/phpstan.neon
index 653f71ea..c9eb57c6 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -10,10 +10,3 @@ parameters:
- src
- test
treatPhpDocTypesAsCertain: false
- ignoreErrors:
- -
- message: '#Call to an undefined method.*setAllowOverride#'
- path: test/Functional/AbstractFunctionalTest.php
- -
- message: '#Call to an undefined method.*setService#'
- path: test/Functional/AbstractFunctionalTest.php
diff --git a/src/Admin/src/Command/AdminCreateCommand.php b/src/Admin/src/Command/AdminCreateCommand.php
index 0078c127..fc21a0f7 100644
--- a/src/Admin/src/Command/AdminCreateCommand.php
+++ b/src/Admin/src/Command/AdminCreateCommand.php
@@ -5,9 +5,10 @@
namespace Api\Admin\Command;
use Api\Admin\InputFilter\CreateAdminInputFilter;
+use Api\Admin\Service\AdminRoleServiceInterface;
+use Api\Admin\Service\AdminServiceInterface;
use Core\Admin\Entity\AdminRole;
-use Core\Admin\Service\AdminRoleServiceInterface;
-use Core\Admin\Service\AdminServiceInterface;
+use Core\Admin\Enum\AdminRoleEnum;
use Core\App\Exception\BadRequestException;
use Core\App\Exception\ConflictException;
use Core\App\Exception\NotFoundException;
@@ -78,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new BadRequestException(implode(PHP_EOL, $messages));
}
- $this->adminService->createAdmin($inputFilter->getValues());
+ $this->adminService->saveAdmin($inputFilter->getValues());
(new SymfonyStyle($input, $output))->info(Message::ADMIN_CREATED);
@@ -90,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function getData(InputInterface $input): array
{
- $adminRole = $this->adminRoleService->getAdminRoleRepository()->findOneBy(['name' => AdminRole::ROLE_ADMIN]);
+ $adminRole = $this->adminRoleService->getAdminRoleRepository()->findOneBy(['name' => AdminRoleEnum::Admin]);
if (! $adminRole instanceof AdminRole) {
throw new NotFoundException(Message::ROLE_NOT_FOUND);
}
diff --git a/src/Admin/src/ConfigProvider.php b/src/Admin/src/ConfigProvider.php
index a79ffe9e..ccef15bc 100644
--- a/src/Admin/src/ConfigProvider.php
+++ b/src/Admin/src/ConfigProvider.php
@@ -16,6 +16,10 @@
use Api\Admin\Handler\Admin\PostAdminResourceHandler;
use Api\Admin\Handler\Admin\Role\GetAdminRoleCollectionHandler;
use Api\Admin\Handler\Admin\Role\GetAdminRoleResourceHandler;
+use Api\Admin\Service\AdminRoleService;
+use Api\Admin\Service\AdminRoleServiceInterface;
+use Api\Admin\Service\AdminService;
+use Api\Admin\Service\AdminServiceInterface;
use Api\App\ConfigProvider as AppConfigProvider;
use Api\App\Factory\HandlerDelegatorFactory;
use Core\Admin\Entity\Admin;
@@ -60,6 +64,12 @@ private function getDependencies(): array
PatchAdminAccountResourceHandler::class => AttributedServiceFactory::class,
PatchAdminResourceHandler::class => AttributedServiceFactory::class,
PostAdminResourceHandler::class => AttributedServiceFactory::class,
+ AdminService::class => AttributedServiceFactory::class,
+ AdminRoleService::class => AttributedServiceFactory::class,
+ ],
+ 'aliases' => [
+ AdminServiceInterface::class => AdminService::class,
+ AdminRoleServiceInterface::class => AdminRoleService::class,
],
];
}
diff --git a/src/Admin/src/Handler/Account/PatchAdminAccountResourceHandler.php b/src/Admin/src/Handler/Account/PatchAdminAccountResourceHandler.php
index 6bc900f7..1bbfd039 100644
--- a/src/Admin/src/Handler/Account/PatchAdminAccountResourceHandler.php
+++ b/src/Admin/src/Handler/Account/PatchAdminAccountResourceHandler.php
@@ -5,9 +5,9 @@
namespace Api\Admin\Handler\Account;
use Api\Admin\InputFilter\UpdateAdminInputFilter;
+use Api\Admin\Service\AdminServiceInterface;
use Api\App\Handler\AbstractHandler;
use Core\Admin\Entity\Admin;
-use Core\Admin\Service\AdminServiceInterface;
use Core\App\Exception\BadRequestException;
use Core\App\Exception\ConflictException;
use Core\App\Exception\NotFoundException;
@@ -39,9 +39,12 @@ public function handle(ServerRequestInterface $request): ResponseInterface
throw (new BadRequestException())->setMessages($this->inputFilter->getMessages());
}
- $admin = $request->getAttribute(Admin::class);
- $this->adminService->updateAdmin($admin, (array) $this->inputFilter->getValues());
-
- return $this->createResponse($request, $admin);
+ return $this->createResponse(
+ $request,
+ $this->adminService->saveAdmin(
+ (array) $this->inputFilter->getValues(),
+ $request->getAttribute(Admin::class)
+ )
+ );
}
}
diff --git a/src/Admin/src/Handler/Admin/DeleteAdminResourceHandler.php b/src/Admin/src/Handler/Admin/DeleteAdminResourceHandler.php
index 2f55de23..c5e4d5a9 100644
--- a/src/Admin/src/Handler/Admin/DeleteAdminResourceHandler.php
+++ b/src/Admin/src/Handler/Admin/DeleteAdminResourceHandler.php
@@ -4,8 +4,8 @@
namespace Api\Admin\Handler\Admin;
+use Api\Admin\Service\AdminServiceInterface;
use Api\App\Handler\AbstractHandler;
-use Core\Admin\Service\AdminServiceInterface;
use Core\App\Exception\NotFoundException;
use Dot\DependencyInjection\Attribute\Inject;
use Psr\Http\Message\ResponseInterface;
@@ -26,9 +26,7 @@ public function __construct(
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
- $this->adminService->getAdminRepository()->deleteAdmin(
- $this->adminService->find($request->getAttribute('uuid'))
- );
+ $this->adminService->deleteAdmin($this->adminService->findAdmin($request->getAttribute('uuid')));
return $this->noContentResponse();
}
diff --git a/src/Admin/src/Handler/Admin/GetAdminCollectionHandler.php b/src/Admin/src/Handler/Admin/GetAdminCollectionHandler.php
index 000f3d7c..ee28bde3 100644
--- a/src/Admin/src/Handler/Admin/GetAdminCollectionHandler.php
+++ b/src/Admin/src/Handler/Admin/GetAdminCollectionHandler.php
@@ -5,9 +5,8 @@
namespace Api\Admin\Handler\Admin;
use Api\Admin\Collection\AdminCollection;
+use Api\Admin\Service\AdminServiceInterface;
use Api\App\Handler\AbstractHandler;
-use Core\Admin\Service\AdminServiceInterface;
-use Core\App\Exception\BadRequestException;
use Dot\DependencyInjection\Attribute\Inject;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@@ -22,14 +21,11 @@ public function __construct(
) {
}
- /**
- * @throws BadRequestException
- */
public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->createResponse(
$request,
- new AdminCollection($this->adminService->getAdminRepository()->getAdmins($request->getQueryParams()))
+ new AdminCollection($this->adminService->getAdmins($request->getQueryParams()))
);
}
}
diff --git a/src/Admin/src/Handler/Admin/GetAdminResourceHandler.php b/src/Admin/src/Handler/Admin/GetAdminResourceHandler.php
index bbbbf2f8..ae68718b 100644
--- a/src/Admin/src/Handler/Admin/GetAdminResourceHandler.php
+++ b/src/Admin/src/Handler/Admin/GetAdminResourceHandler.php
@@ -4,8 +4,8 @@
namespace Api\Admin\Handler\Admin;
+use Api\Admin\Service\AdminServiceInterface;
use Api\App\Handler\AbstractHandler;
-use Core\Admin\Service\AdminServiceInterface;
use Core\App\Exception\NotFoundException;
use Dot\DependencyInjection\Attribute\Inject;
use Psr\Http\Message\ResponseInterface;
@@ -28,7 +28,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->createResponse(
$request,
- $this->adminService->find($request->getAttribute('uuid'))
+ $this->adminService->findAdmin($request->getAttribute('uuid'))
);
}
}
diff --git a/src/Admin/src/Handler/Admin/PatchAdminResourceHandler.php b/src/Admin/src/Handler/Admin/PatchAdminResourceHandler.php
index 0cc1e863..906eba6b 100644
--- a/src/Admin/src/Handler/Admin/PatchAdminResourceHandler.php
+++ b/src/Admin/src/Handler/Admin/PatchAdminResourceHandler.php
@@ -5,8 +5,8 @@
namespace Api\Admin\Handler\Admin;
use Api\Admin\InputFilter\UpdateAdminInputFilter;
+use Api\Admin\Service\AdminServiceInterface;
use Api\App\Handler\AbstractHandler;
-use Core\Admin\Service\AdminServiceInterface;
use Core\App\Exception\BadRequestException;
use Core\App\Exception\ConflictException;
use Core\App\Exception\NotFoundException;
@@ -38,10 +38,12 @@ public function handle(ServerRequestInterface $request): ResponseInterface
throw (new BadRequestException())->setMessages($this->inputFilter->getMessages());
}
- $admin = $this->adminService->find($request->getAttribute('uuid'));
-
- $this->adminService->updateAdmin($admin, (array) $this->inputFilter->getValues());
-
- return $this->createResponse($request, $admin);
+ return $this->createResponse(
+ $request,
+ $this->adminService->saveAdmin(
+ (array) $this->inputFilter->getValues(),
+ $this->adminService->findAdmin($request->getAttribute('uuid'))
+ )
+ );
}
}
diff --git a/src/Admin/src/Handler/Admin/PostAdminResourceHandler.php b/src/Admin/src/Handler/Admin/PostAdminResourceHandler.php
index 19059d24..c40c47f3 100644
--- a/src/Admin/src/Handler/Admin/PostAdminResourceHandler.php
+++ b/src/Admin/src/Handler/Admin/PostAdminResourceHandler.php
@@ -5,8 +5,8 @@
namespace Api\Admin\Handler\Admin;
use Api\Admin\InputFilter\CreateAdminInputFilter;
+use Api\Admin\Service\AdminServiceInterface;
use Api\App\Handler\AbstractHandler;
-use Core\Admin\Service\AdminServiceInterface;
use Core\App\Exception\BadRequestException;
use Core\App\Exception\ConflictException;
use Core\App\Exception\NotFoundException;
@@ -40,7 +40,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
return $this->createdResponse(
$request,
- $this->adminService->createAdmin((array) $this->inputFilter->getValues())
+ $this->adminService->saveAdmin((array) $this->inputFilter->getValues())
);
}
}
diff --git a/src/Admin/src/Handler/Admin/Role/GetAdminRoleCollectionHandler.php b/src/Admin/src/Handler/Admin/Role/GetAdminRoleCollectionHandler.php
index 61730701..c94ceb3d 100644
--- a/src/Admin/src/Handler/Admin/Role/GetAdminRoleCollectionHandler.php
+++ b/src/Admin/src/Handler/Admin/Role/GetAdminRoleCollectionHandler.php
@@ -5,9 +5,8 @@
namespace Api\Admin\Handler\Admin\Role;
use Api\Admin\Collection\AdminRoleCollection;
+use Api\Admin\Service\AdminRoleServiceInterface;
use Api\App\Handler\AbstractHandler;
-use Core\Admin\Service\AdminRoleServiceInterface;
-use Core\App\Exception\BadRequestException;
use Dot\DependencyInjection\Attribute\Inject;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@@ -22,15 +21,12 @@ public function __construct(
) {
}
- /**
- * @throws BadRequestException
- */
public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->createResponse(
$request,
new AdminRoleCollection(
- $this->adminRoleService->getAdminRoleRepository()->getAdminRoles($request->getQueryParams())
+ $this->adminRoleService->getAdminRoles($request->getQueryParams())
)
);
}
diff --git a/src/Admin/src/Handler/Admin/Role/GetAdminRoleResourceHandler.php b/src/Admin/src/Handler/Admin/Role/GetAdminRoleResourceHandler.php
index 479247c8..c3260670 100644
--- a/src/Admin/src/Handler/Admin/Role/GetAdminRoleResourceHandler.php
+++ b/src/Admin/src/Handler/Admin/Role/GetAdminRoleResourceHandler.php
@@ -4,8 +4,8 @@
namespace Api\Admin\Handler\Admin\Role;
+use Api\Admin\Service\AdminRoleServiceInterface;
use Api\App\Handler\AbstractHandler;
-use Core\Admin\Service\AdminRoleServiceInterface;
use Core\App\Exception\NotFoundException;
use Dot\DependencyInjection\Attribute\Inject;
use Psr\Http\Message\ResponseInterface;
@@ -28,7 +28,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->createResponse(
$request,
- $this->adminRoleService->find($request->getAttribute('uuid'))
+ $this->adminRoleService->findAdminRole($request->getAttribute('uuid'))
);
}
}
diff --git a/src/Admin/src/InputFilter/AdminRoleInputFilter.php b/src/Admin/src/InputFilter/AdminRoleInputFilter.php
index dfa10e4a..021b9621 100644
--- a/src/Admin/src/InputFilter/AdminRoleInputFilter.php
+++ b/src/Admin/src/InputFilter/AdminRoleInputFilter.php
@@ -4,13 +4,10 @@
namespace Api\Admin\InputFilter;
-use Api\Admin\InputFilter\Input\UuidInput;
-use Laminas\InputFilter\InputFilter;
+use Api\App\InputFilter\Input\UuidInput;
+use Core\App\InputFilter\AbstractInputFilter;
-/**
- * @extends InputFilter