* watcher api endpoint implemented

This commit is contained in:
Dávid Danyi
2018-09-12 17:20:15 +02:00
parent 9d3fa5fa9d
commit 3d42f16c38
9 changed files with 378 additions and 14 deletions

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\Handler;
use App\Entity\KanbanBoard;
use App\Service\JiraCollectorService;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response\JsonResponse;
class WatchedHandler implements RequestHandlerInterface
{
/** @var JiraCollectorService */
private $dataCollector;
/**
* KanbanAction constructor.
* @param JiraCollectorService $dataCollectorService
*/
public function __construct(JiraCollectorService $dataCollectorService)
{
$this->dataCollector = $dataCollectorService;
}
/**
* @param ServerRequestInterface $request
* @return ResponseInterface
* @todo filterId
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
$teamId = (int)$request->getAttribute('teamId');
/** @var KanbanBoard $kanbanResult */
$kanbanResult = $this->dataCollector->getTeamWatchedIssues($teamId);
return new JsonResponse($kanbanResult);
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Handler;
use App\Service\JiraCollectorService;
use Interop\Container\ContainerInterface;
class WatchedHandlerFactory
{
/**
* @param ContainerInterface $container
* @return WatchedHandler
*/
public function __invoke(ContainerInterface $container)
{
/** @var JiraCollectorService $dataCollectorService */
$dataCollectorService = $container->get(JiraCollectorService::class);
return new WatchedHandler($dataCollectorService);
}
}