* watcher api endpoint implemented
This commit is contained in:
40
src/App/Handler/WatchedHandler.php
Executable file
40
src/App/Handler/WatchedHandler.php
Executable 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);
|
||||
}
|
||||
}
|
||||
22
src/App/Handler/WatchedHandlerFactory.php
Executable file
22
src/App/Handler/WatchedHandlerFactory.php
Executable 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user