Aktionen
GX-Feature #70204
geschlossenImplement registration of routes with php attribute in addition to routes.php
Status:
Abgewiesen
Priorität:
Normal
Zugewiesen an:
Tobias Schindler
Kategorie:
REST-API
Zielversion:
-
% erledigt:
0%
Geschätzter Aufwand:
Steps to reproduce:
Betroffene Versionen:
Unbestimmt
Release Notes Langtext:
Beschreibung
One of php8.0 new features are the attributes. With which custom information can be parsed more easily. Frameworks like Symphony use this to register methods of controller classes to a specific route.
This should also be possible for our action classes. Instead of mapping a class in a dedicated routes.php this example code should also be valid
declare(strict_types=1);
namespace Gambio\Api\Modules\Customer\Submodules\Memos\App\Actions;
use Gambio\Core\Application\Http\Request;
use Gambio\Core\Application\Http\Response;
use Gambio\Core\Application\Routing\Attribute\Route;
/**
* Class TestRouteWithAttribute
*
* @package Gambio\Api\Modules\Customer\Submodules\Memos\App\Actions
*/
#[Route('/api.php/v3/test-attributes', 'GET')]
class TestRouteWithAttribute
{
/**
* @param Request $request
* @param Response $response
* @param array $args
*
* @return Response
*/
public function __invoke(Request $request, Response $response, array $args): Response
{
return $response->withJson(['success' => 1]);
}
}
This would also make it easier to see the exact route is assigned to an action without needing to look it up in the routes.php
Checkliste 0/0
Von Marvin Muxfeld vor mehr als 2 Jahren aktualisiert
- Status wurde von In Bearbeitung zu Feedback geändert
- Zugewiesen an wurde von Marvin Muxfeld zu Tobias Schindler geändert
Von Tobias Schindler vor mehr als 2 Jahren aktualisiert
- Status wurde von Feedback zu Abgewiesen geändert
Aktionen