src/Rest/Traits/Actions/Root/DeleteAction.php
<?php
declare(strict_types = 1);
/**
* /src/Rest/Traits/Actions/Root/DeleteAction.php
*
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
namespace App\Rest\Traits\Actions\Root;
use App\Enum\Role;
use App\Rest\Traits\Methods\DeleteMethod;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Requirement\Requirement;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Throwable;
/**
* Trait to add 'deleteAction' for REST controllers for 'ROLE_ROOT' users.
*
* @see \App\Rest\Traits\Methods\DeleteMethod for detailed documents.
*
* @package App\Rest\Traits\Actions\Root
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
trait DeleteAction
{
use DeleteMethod;
/**
* @throws Throwable
*/
#[Route(
path: '/{id}',
requirements: [
'id' => Requirement::UUID_V1,
],
methods: [Request::METHOD_DELETE],
)]
#[IsGranted(Role::ROOT->value)]
public function deleteAction(Request $request, string $id): Response
{
return $this->deleteMethod($request, $id);
}
}