API endpoint for Timesheet entries (#332)

This commit is contained in:
Kevin Papst
2018-11-18 19:43:58 +01:00
committed by GitHub
parent 8cb52e22b1
commit b1c06eed7b
35 changed files with 1073 additions and 118 deletions

View File

@@ -19,10 +19,8 @@ use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\Request\ParamFetcherInterface;
use FOS\RestBundle\View\View;
use FOS\RestBundle\View\ViewHandlerInterface;
use Nelmio\ApiDocBundle\Annotation\Model;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Swagger\Annotations as SWG;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
@@ -30,7 +28,7 @@ use Symfony\Component\HttpFoundation\Response;
*
* @Security("is_granted('ROLE_USER')")
*/
class ProjectController extends Controller
class ProjectController extends BaseApiController
{
/**
* @var ProjectRepository
@@ -54,12 +52,12 @@ class ProjectController extends Controller
/**
* @SWG\Response(
* response=200,
* description="Returns the collection of all existing projects",
* @SWG\Schema(ref=@Model(type=Project::class)),
* response=200,
* description="Returns the collection of all existing projects",
* @SWG\Schema(ref="#/definitions/ProjectCollection"),
* )
* @Rest\QueryParam(name="customer", requirements="\d+", strict=true, nullable=true, description="Customer ID to filter projects")
* @Rest\QueryParam(name="visible", requirements="\d+", strict=true, nullable=true, description="Visibility status to filter projects")
* @Rest\QueryParam(name="visible", requirements="\d+", strict=true, nullable=true, description="Visibility status to filter projects (1=visible, 2=hidden, 3=both)")
*
* @param ParamFetcherInterface $paramFetcher
* @return Response
@@ -79,15 +77,16 @@ class ProjectController extends Controller
$data = $this->repository->findByQuery($query);
$view = new View($data, 200);
$view->getContext()->setGroups(['Default', 'Collection', 'Project']);
return $this->viewHandler->handle($view);
}
/**
* @SWG\Response(
* response=200,
* description="Returns one project entity",
* @SWG\Schema(ref=@Model(type=Project::class)),
* response=200,
* description="Returns one project entity",
* @SWG\Schema(ref="#/definitions/ProjectEntity"),
* )
*
* @param int $id
@@ -100,6 +99,7 @@ class ProjectController extends Controller
throw new NotFoundException();
}
$view = new View($data, 200);
$view->getContext()->setGroups(['Default', 'Entity', 'Project']);
return $this->viewHandler->handle($view);
}