80 lines
2.8 KiB
PHP
80 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace TorstenHettstedt\TimekeepingApi\Controller;
|
|
|
|
|
|
use Exception;
|
|
use Fig\Http\Message\StatusCodeInterface;
|
|
use Slim\Exception\HttpInternalServerErrorException;
|
|
use Slim\Psr7\Request;
|
|
use Slim\Psr7\Response;
|
|
use TorstenHettstedt\TimekeepingApi\Repositories\WorkingHoursMonthlyViewRepository;
|
|
use TorstenHettstedt\TimekeepingApi\Repositories\WorkingHoursWeeklyViewRepository;
|
|
use TorstenHettstedt\TimekeepingApi\Repositories\WorkingHoursYearlyViewRepository;
|
|
|
|
class WorkingHoursViewController extends AbstractController
|
|
{
|
|
/**
|
|
* @param Request $request
|
|
* @param Response $response
|
|
* @param mixed[] $args
|
|
*
|
|
* @return Response
|
|
*
|
|
* @throws HttpInternalServerErrorException
|
|
* @noinspection PhpUnusedParameterInspection
|
|
*/
|
|
public function browseWeekly(Request $request, Response $response, array $args): Response
|
|
{
|
|
$repository = new WorkingHoursWeeklyViewRepository($this->databases);
|
|
try {
|
|
return $this->printResponse($response, $repository->findAll(), StatusCodeInterface::STATUS_OK);
|
|
} catch (Exception $exception) {
|
|
throw new HttpInternalServerErrorException($request,
|
|
'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank', $exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @param Response $response
|
|
* @param mixed[] $args
|
|
*
|
|
* @return Response
|
|
*
|
|
* @throws HttpInternalServerErrorException
|
|
* @noinspection PhpUnusedParameterInspection
|
|
*/
|
|
public function browseMonthly(Request $request, Response $response, array $args): Response
|
|
{
|
|
$repository = new WorkingHoursMonthlyViewRepository($this->databases);
|
|
try {
|
|
return $this->printResponse($response, $repository->findAll(), StatusCodeInterface::STATUS_OK);
|
|
} catch (Exception $exception) {
|
|
throw new HttpInternalServerErrorException($request,
|
|
'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank', $exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @param Response $response
|
|
* @param mixed[] $args
|
|
*
|
|
* @return Response
|
|
*
|
|
* @throws HttpInternalServerErrorException
|
|
* @noinspection PhpUnusedParameterInspection
|
|
*/
|
|
public function browseYearly(Request $request, Response $response, array $args): Response
|
|
{
|
|
$repository = new WorkingHoursYearlyViewRepository($this->databases);
|
|
try {
|
|
return $this->printResponse($response, $repository->findAll(), StatusCodeInterface::STATUS_OK);
|
|
} catch (Exception $exception) {
|
|
throw new HttpInternalServerErrorException($request,
|
|
'Der Wert für das Datum oder die Zeit ist falsch in der Datenbank', $exception);
|
|
}
|
|
}
|
|
|
|
} |