Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
/*
* This file is part of the Kimai time-tracking app.
*
@@ -17,65 +15,40 @@ use App\Entity\Project;
use App\Entity\Team;
use App\Entity\User;
use App\Form\API\TeamApiEditForm;
use App\Repository\ActivityRepository;
use App\Repository\CustomerRepository;
use App\Repository\ProjectRepository;
use App\Repository\TeamRepository;
use App\Repository\UserRepository;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\View\View;
use FOS\RestBundle\View\ViewHandlerInterface;
use HandcraftedInTheAlps\RestRoutingBundle\Controller\Annotations\RouteResource;
use Nelmio\ApiDocBundle\Annotation\Security as ApiSecurity;
use OpenApi\Attributes as OA;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
/**
* @RouteResource("Team")
* @SWG\Tag(name="Team")
*
* @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')")
*/
#[Route(path: '/teams')]
#[Security("is_granted('IS_AUTHENTICATED_REMEMBERED')")]
#[OA\Tag(name: 'Team')]
final class TeamController extends BaseApiController
{
public const GROUPS_ENTITY = ['Default', 'Entity', 'Team', 'Team_Entity', 'Not_Expanded'];
public const GROUPS_FORM = ['Default', 'Entity', 'Team', 'Team_Entity', 'Not_Expanded'];
public const GROUPS_COLLECTION = ['Default', 'Collection', 'Team'];
/**
* @var TeamRepository
*/
private $repository;
/**
* @var ViewHandlerInterface
*/
private $viewHandler;
public function __construct(ViewHandlerInterface $viewHandler, TeamRepository $repository)
public function __construct(private ViewHandlerInterface $viewHandler, private TeamRepository $repository)
{
$this->viewHandler = $viewHandler;
$this->repository = $repository;
}
/**
* Fetch all existing teams
*
* @SWG\Response(
* response=200,
* description="Returns the collection of all existing teams",
* @SWG\Schema(
* type="array",
* @SWG\Items(ref="#/definitions/TeamCollection")
* )
* )
*
* @Security("is_granted('view_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
* Fetch all existing teams (which are visible to the user)
*/
#[Security("is_granted('view_team')")]
#[OA\Response(response: 200, description: 'Returns the collection of teams', content: new OA\JsonContent(type: 'array', items: new OA\Items(ref: '#/components/schemas/TeamCollection')))]
#[Rest\Get(path: '', name: 'get_teams')]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
public function cgetAction(): Response
{
$data = $this->repository->findAll();
@@ -88,27 +61,15 @@ final class TeamController extends BaseApiController
/**
* Returns one team
*
* @SWG\Response(
* response=200,
* description="Returns one team entity",
* @SWG\Schema(ref="#/definitions/Team"),
* )
*
* @Security("is_granted('view_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function getAction(int $id): Response
#[Security("is_granted('view_team')")]
#[OA\Response(response: 200, description: 'Returns one team entity', content: new OA\JsonContent(ref: '#/components/schemas/Team'))]
#[Rest\Get(path: '/{id}', name: 'get_team', requirements: ['id' => '\d+'])]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
public function getAction(Team $team): Response
{
$data = $this->repository->find($id);
if (null === $data) {
throw new NotFoundException();
}
$view = new View($data, 200);
$view = new View($team, 200);
$view->getContext()->setGroups(self::GROUPS_ENTITY);
return $this->viewHandler->handle($view);
@@ -116,34 +77,15 @@ final class TeamController extends BaseApiController
/**
* Delete a team
*
* @SWG\Delete(
* @SWG\Response(
* response=204,
* description="Delete one team"
* ),
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="Team ID to delete",
* required=true,
* )
*
* @Security("is_granted('delete_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function deleteAction(int $id): Response
#[Security("is_granted('delete_team')")]
#[OA\Delete(responses: [new OA\Response(response: 204, description: 'Delete one team')])]
#[OA\Parameter(name: 'id', in: 'path', description: 'Team ID to delete', required: true)]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Rest\Delete(path: '/{id}', name: 'delete_team', requirements: ['id' => '\d+'])]
public function deleteAction(Team $team): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException();
}
$this->repository->deleteTeam($team);
$view = new View(null, Response::HTTP_NO_CONTENT);
@@ -153,30 +95,16 @@ final class TeamController extends BaseApiController
/**
* Creates a new team
*
* @SWG\Post(
* description="Creates a new team and returns it afterwards",
* @SWG\Response(
* response=200,
* description="Returns the new created team",
* @SWG\Schema(ref="#/definitions/Team"),
* )
* )
* @SWG\Parameter(
* name="body",
* in="body",
* required=true,
* @SWG\Schema(ref="#/definitions/TeamEditForm")
* )
*
* @Security("is_granted('create_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
#[Security("is_granted('create_team')")]
#[OA\Post(description: 'Creates a new team and returns it afterwards', responses: [new OA\Response(response: 200, description: 'Returns the new created team', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\RequestBody(required: true, content: new OA\JsonContent(ref: '#/components/schemas/TeamEditForm'))]
#[Rest\Post(path: '', name: 'post_team')]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
public function postAction(Request $request): Response
{
$team = new Team();
$team = new Team('');
$form = $this->createForm(TeamApiEditForm::class, $team);
$form->submit($request->request->all());
@@ -198,42 +126,16 @@ final class TeamController extends BaseApiController
/**
* Update an existing team
*
* @SWG\Patch(
* description="Update an existing team, you can pass all or just a subset of all attributes (passing members will replace all existing ones)",
* @SWG\Response(
* response=200,
* description="Returns the updated team",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="body",
* in="body",
* required=true,
* @SWG\Schema(ref="#/definitions/TeamEditForm")
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="Team ID to update",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function patchAction(Request $request, int $id): Response
#[Security("is_granted('edit_team')")]
#[OA\Patch(description: 'Update an existing team, you can pass all or just a subset of all attributes (passing members will replace all existing ones)', responses: [new OA\Response(response: 200, description: 'Returns the updated team', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\RequestBody(required: true, content: new OA\JsonContent(ref: '#/components/schemas/TeamEditForm'))]
#[OA\Parameter(name: 'id', in: 'path', description: 'Team ID to update', required: true)]
#[Rest\Patch(path: '/{id}', name: 'patch_team', requirements: ['id' => '\d+'])]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
public function patchAction(Request $request, Team $team): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException();
}
if ($request->request->has('members')) {
foreach ($team->getMembers() as $member) {
$team->removeMember($member);
@@ -264,54 +166,22 @@ final class TeamController extends BaseApiController
/**
* Add a new member to a team
*
* @SWG\Post(
* @SWG\Response(
* response=200,
* description="Adds a new user to a team.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team which will receive the new member",
* required=true,
* )
* @SWG\Parameter(
* name="userId",
* in="path",
* type="integer",
* description="The team member to add (User ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function postMemberAction(int $id, int $userId, UserRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Post(responses: [new OA\Response(response: 200, description: 'Adds a new user to a team.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team which will receive the new member', required: true)]
#[OA\Parameter(name: 'userId', in: 'path', description: 'The team member to add (User ID)', required: true)]
#[Rest\Post(path: '/{id}/members/{userId}', name: 'post_team_member', requirements: ['id' => '\d+', 'userId' => '\d+'])]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Entity('member', expr: 'repository.find(userId)')]
public function postMemberAction(Team $team, User $member): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var User|null $user */
$user = $repository->find($userId);
if (null === $user) {
throw new NotFoundException('User not found');
}
if ($user->isInTeam($team)) {
if ($member->isInTeam($team)) {
throw new BadRequestHttpException('User is already member of the team');
}
$team->addUser($user);
$team->addUser($member);
$this->repository->saveTeam($team);
@@ -323,58 +193,26 @@ final class TeamController extends BaseApiController
/**
* Removes a member from the team
*
* @SWG\Delete(
* @SWG\Response(
* response=200,
* description="Removes a user from the team. The teamlead cannot be removed.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team from which the member will be removed",
* required=true,
* )
* @SWG\Parameter(
* name="userId",
* in="path",
* type="integer",
* description="The team member to remove (User ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function deleteMemberAction(int $id, int $userId, UserRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Delete(responses: [new OA\Response(response: 200, description: 'Removes a user from the team. The teamlead cannot be removed.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team from which the member will be removed', required: true)]
#[OA\Parameter(name: 'userId', in: 'path', description: 'The team member to remove (User ID)', required: true)]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Rest\Delete(path: '/{id}/members/{userId}', name: 'delete_team_member', requirements: ['id' => '\d+', 'userId' => '\d+'])]
#[Entity('member', expr: 'repository.find(userId)')]
public function deleteMemberAction(Team $team, User $member): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var User|null $user */
$user = $repository->find($userId);
if (null === $user) {
throw new NotFoundException('User not found');
}
if (!$user->isInTeam($team)) {
if (!$member->isInTeam($team)) {
throw new BadRequestHttpException('User is not a member of the team');
}
if ($team->isTeamlead($user)) {
if ($team->isTeamlead($member)) {
throw new BadRequestHttpException('Cannot remove teamlead');
}
$team->removeUser($user);
$team->removeUser($member);
$this->repository->saveTeam($team);
@@ -386,49 +224,17 @@ final class TeamController extends BaseApiController
/**
* Grant the team access to a customer
*
* @SWG\Post(
* @SWG\Response(
* response=200,
* description="Adds a new customer to a team.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team that is granted access",
* required=true,
* )
* @SWG\Parameter(
* name="customerId",
* in="path",
* type="integer",
* description="The customer to grant acecess to (Customer ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function postCustomerAction(int $id, int $customerId, CustomerRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Post(responses: [new OA\Response(response: 200, description: 'Adds a new customer to a team.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team that is granted access', required: true)]
#[OA\Parameter(name: 'customerId', in: 'path', description: 'The customer to grant acecess to (Customer ID)', required: true)]
#[Rest\Post(path: '/{id}/customers/{customerId}', name: 'post_team_customer', requirements: ['id' => '\d+', 'customerId' => '\d+'])]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Entity('customer', expr: 'repository.find(customerId)')]
public function postCustomerAction(Team $team, Customer $customer): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var Customer|null $customer */
$customer = $repository->find($customerId);
if (null === $customer) {
throw new NotFoundException('Customer not found');
}
if ($team->hasCustomer($customer)) {
throw new BadRequestHttpException('Team has already access to customer');
}
@@ -445,49 +251,17 @@ final class TeamController extends BaseApiController
/**
* Revokes access for a customer from a team
*
* @SWG\Delete(
* @SWG\Response(
* response=200,
* description="Removes a customer from the team.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team whose permission will be revoked",
* required=true,
* )
* @SWG\Parameter(
* name="customerId",
* in="path",
* type="integer",
* description="The customer to remove (Customer ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function deleteCustomerAction(int $id, int $customerId, CustomerRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Delete(responses: [new OA\Response(response: 200, description: 'Removes a customer from the team.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team whose permission will be revoked', required: true)]
#[OA\Parameter(name: 'customerId', in: 'path', description: 'The customer to remove (Customer ID)', required: true)]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Rest\Delete(path: '/{id}/customers/{customerId}', name: 'delete_team_customer', requirements: ['id' => '\d+', 'customerId' => '\d+'])]
#[Entity('customer', expr: 'repository.find(customerId)')]
public function deleteCustomerAction(Team $team, Customer $customer): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var Customer|null $customer */
$customer = $repository->find($customerId);
if (null === $customer) {
throw new NotFoundException('Customer not found');
}
if (!$team->hasCustomer($customer)) {
throw new BadRequestHttpException('Customer is not assigned to the team');
}
@@ -504,49 +278,17 @@ final class TeamController extends BaseApiController
/**
* Grant the team access to a project
*
* @SWG\Post(
* @SWG\Response(
* response=200,
* description="Adds a new project to a team.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team that is granted access",
* required=true,
* )
* @SWG\Parameter(
* name="projectId",
* in="path",
* type="integer",
* description="The project to grant acecess to (Project ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function postProjectAction(int $id, int $projectId, ProjectRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Post(responses: [new OA\Response(response: 200, description: 'Adds a new project to a team.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team that is granted access', required: true)]
#[OA\Parameter(name: 'projectId', in: 'path', description: 'The project to grant acecess to (Project ID)', required: true)]
#[Rest\Post(path: '/{id}/projects/{projectId}', name: 'post_team_project', requirements: ['id' => '\d+', 'projectId' => '\d+'])]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Entity('project', expr: 'repository.find(projectId)')]
public function postProjectAction(Team $team, Project $project): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var Project|null $project */
$project = $repository->find($projectId);
if (null === $project) {
throw new NotFoundException('Project not found');
}
if ($team->hasProject($project)) {
throw new BadRequestHttpException('Team has already access to project');
}
@@ -563,49 +305,17 @@ final class TeamController extends BaseApiController
/**
* Revokes access for a project from a team
*
* @SWG\Delete(
* @SWG\Response(
* response=200,
* description="Removes a project from the team.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team whose permission will be revoked",
* required=true,
* )
* @SWG\Parameter(
* name="projectId",
* in="path",
* type="integer",
* description="The project to remove (Project ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function deleteProjectAction(int $id, int $projectId, ProjectRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Delete(responses: [new OA\Response(response: 200, description: 'Removes a project from the team.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team whose permission will be revoked', required: true)]
#[OA\Parameter(name: 'projectId', in: 'path', description: 'The project to remove (Project ID)', required: true)]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Rest\Delete(path: '/{id}/projects/{projectId}', name: 'delete_team_project', requirements: ['id' => '\d+', 'projectId' => '\d+'])]
#[Entity('project', expr: 'repository.find(projectId)')]
public function deleteProjectAction(Team $team, Project $project): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var Project|null $project */
$project = $repository->find($projectId);
if (null === $project) {
throw new NotFoundException('Project not found');
}
if (!$team->hasProject($project)) {
throw new BadRequestHttpException('Project is not assigned to the team');
}
@@ -622,49 +332,17 @@ final class TeamController extends BaseApiController
/**
* Grant the team access to an activity
*
* @SWG\Post(
* @SWG\Response(
* response=200,
* description="Adds a new activity to a team.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team that is granted access",
* required=true,
* )
* @SWG\Parameter(
* name="activityId",
* in="path",
* type="integer",
* description="The activity to grant acecess to (Activity ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function postActivityAction(int $id, int $activityId, ActivityRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Post(responses: [new OA\Response(response: 200, description: 'Adds a new activity to a team.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team that is granted access', required: true)]
#[OA\Parameter(name: 'activityId', in: 'path', description: 'The activity to grant acecess to (Activity ID)', required: true)]
#[Rest\Post(path: '/{id}/activities/{activityId}', name: 'post_team_activity', requirements: ['id' => '\d+', 'activityId' => '\d+'])]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Entity('activity', expr: 'repository.find(activityId)')]
public function postActivityAction(Team $team, Activity $activity): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var Activity|null $activity */
$activity = $repository->find($activityId);
if (null === $activity) {
throw new NotFoundException('Activity not found');
}
if ($team->hasActivity($activity)) {
throw new BadRequestHttpException('Team has already access to activity');
}
@@ -681,49 +359,17 @@ final class TeamController extends BaseApiController
/**
* Revokes access for an activity from a team
*
* @SWG\Delete(
* @SWG\Response(
* response=200,
* description="Removes a activity from the team.",
* @SWG\Schema(ref="#/definitions/Team")
* )
* )
* @SWG\Parameter(
* name="id",
* in="path",
* type="integer",
* description="The team whose permission will be revoked",
* required=true,
* )
* @SWG\Parameter(
* name="activityId",
* in="path",
* type="integer",
* description="The activity to remove (Activity ID)",
* required=true,
* )
*
* @Security("is_granted('edit_team')")
*
* @ApiSecurity(name="apiUser")
* @ApiSecurity(name="apiToken")
*/
public function deleteActivityAction(int $id, int $activityId, ActivityRepository $repository): Response
#[Security("is_granted('edit_team')")]
#[OA\Delete(responses: [new OA\Response(response: 200, description: 'Removes a activity from the team.', content: new OA\JsonContent(ref: '#/components/schemas/Team'))])]
#[OA\Parameter(name: 'id', in: 'path', description: 'The team whose permission will be revoked', required: true)]
#[OA\Parameter(name: 'activityId', in: 'path', description: 'The activity to remove (Activity ID)', required: true)]
#[ApiSecurity(name: 'apiUser')]
#[ApiSecurity(name: 'apiToken')]
#[Rest\Delete(path: '/{id}/activities/{activityId}', name: 'delete_team_activity', requirements: ['id' => '\d+', 'activityId' => '\d+'])]
#[Entity('activity', expr: 'repository.find(activityId)')]
public function deleteActivityAction(Team $team, Activity $activity): Response
{
$team = $this->repository->find($id);
if (null === $team) {
throw new NotFoundException('Team not found');
}
/** @var Activity|null $activity */
$activity = $repository->find($activityId);
if (null === $activity) {
throw new NotFoundException('Activity not found');
}
if (!$team->hasActivity($activity)) {
throw new BadRequestHttpException('Activity is not assigned to the team');
}