Initial commit
This commit is contained in:
33
src/App/Action/AvatarAction.php
Normal file
33
src/App/Action/AvatarAction.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action;
|
||||
|
||||
use App\Service\AvatarService;
|
||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Response\EmptyResponse;
|
||||
use Zend\Diactoros\Response\TextResponse;
|
||||
|
||||
class AvatarAction implements ServerMiddlewareInterface
|
||||
{
|
||||
private $avatarService;
|
||||
|
||||
public function __construct(AvatarService $avatarService)
|
||||
{
|
||||
$this->avatarService = $avatarService;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
||||
{
|
||||
$signum = $request->getAttribute('signum', false);
|
||||
if(!$signum) {
|
||||
return new EmptyResponse();
|
||||
}
|
||||
|
||||
$avatarData = $this->avatarService->getAvatarData($signum);
|
||||
return new TextResponse($avatarData, 200, [
|
||||
'content-type' => 'image/png',
|
||||
]);
|
||||
}
|
||||
}
|
||||
15
src/App/Action/AvatarFactory.php
Normal file
15
src/App/Action/AvatarFactory.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action;
|
||||
|
||||
use App\Service\AvatarService;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class AvatarFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$avatarService = $container->get(AvatarService::class);
|
||||
return new AvatarAction($avatarService);
|
||||
}
|
||||
}
|
||||
63
src/App/Action/HomePageAction.php
Normal file
63
src/App/Action/HomePageAction.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action;
|
||||
|
||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Response\HtmlResponse;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use Zend\Expressive\Router;
|
||||
use Zend\Expressive\Template;
|
||||
use Zend\Expressive\Plates\PlatesRenderer;
|
||||
use Zend\Expressive\Twig\TwigRenderer;
|
||||
use Zend\Expressive\ZendView\ZendViewRenderer;
|
||||
|
||||
class HomePageAction implements ServerMiddlewareInterface
|
||||
{
|
||||
private $router;
|
||||
|
||||
private $template;
|
||||
|
||||
public function __construct(Router\RouterInterface $router, Template\TemplateRendererInterface $template = null)
|
||||
{
|
||||
$this->router = $router;
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
||||
{
|
||||
if (! $this->template) {
|
||||
return new JsonResponse([
|
||||
'welcome' => 'Congratulations! You have installed the zend-expressive skeleton application.',
|
||||
'docsUrl' => 'https://docs.zendframework.com/zend-expressive/',
|
||||
]);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
|
||||
if ($this->router instanceof Router\AuraRouter) {
|
||||
$data['routerName'] = 'Aura.Router';
|
||||
$data['routerDocs'] = 'http://auraphp.com/packages/2.x/Router.html';
|
||||
} elseif ($this->router instanceof Router\FastRouteRouter) {
|
||||
$data['routerName'] = 'FastRoute';
|
||||
$data['routerDocs'] = 'https://github.com/nikic/FastRoute';
|
||||
} elseif ($this->router instanceof Router\ZendRouter) {
|
||||
$data['routerName'] = 'Zend Router';
|
||||
$data['routerDocs'] = 'https://docs.zendframework.com/zend-router/';
|
||||
}
|
||||
|
||||
if ($this->template instanceof PlatesRenderer) {
|
||||
$data['templateName'] = 'Plates';
|
||||
$data['templateDocs'] = 'http://platesphp.com/';
|
||||
} elseif ($this->template instanceof TwigRenderer) {
|
||||
$data['templateName'] = 'Twig';
|
||||
$data['templateDocs'] = 'http://twig.sensiolabs.org/documentation';
|
||||
} elseif ($this->template instanceof ZendViewRenderer) {
|
||||
$data['templateName'] = 'Zend View';
|
||||
$data['templateDocs'] = 'https://docs.zendframework.com/zend-view/';
|
||||
}
|
||||
|
||||
return new HtmlResponse($this->template->render('app::home-page', $data));
|
||||
}
|
||||
}
|
||||
20
src/App/Action/HomePageFactory.php
Normal file
20
src/App/Action/HomePageFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class HomePageFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$router = $container->get(RouterInterface::class);
|
||||
$template = $container->has(TemplateRendererInterface::class)
|
||||
? $container->get(TemplateRendererInterface::class)
|
||||
: null;
|
||||
|
||||
return new HomePageAction($router, $template);
|
||||
}
|
||||
}
|
||||
25
src/App/Action/KanbanAction.php
Normal file
25
src/App/Action/KanbanAction.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action;
|
||||
|
||||
use App\Service\DataCollectorService;
|
||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
|
||||
class KanbanAction implements ServerMiddlewareInterface
|
||||
{
|
||||
private $dataCollector;
|
||||
|
||||
public function __construct(DataCollectorService $dataCollectorService)
|
||||
{
|
||||
$this->dataCollector = $dataCollectorService;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
||||
{
|
||||
$kanbanResult = $this->dataCollector->getKanbanBoard();
|
||||
return new JsonResponse($kanbanResult);
|
||||
}
|
||||
}
|
||||
15
src/App/Action/KanbanFactory.php
Normal file
15
src/App/Action/KanbanFactory.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action;
|
||||
|
||||
use App\Service\DataCollectorService;
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
class KanbanFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$dataCollectorService = $container->get(DataCollectorService::class);
|
||||
return new KanbanAction($dataCollectorService);
|
||||
}
|
||||
}
|
||||
16
src/App/Action/PingAction.php
Normal file
16
src/App/Action/PingAction.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action;
|
||||
|
||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class PingAction implements ServerMiddlewareInterface
|
||||
{
|
||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
||||
{
|
||||
return new JsonResponse(['ack' => time()]);
|
||||
}
|
||||
}
|
||||
77
src/App/ConfigProvider.php
Normal file
77
src/App/ConfigProvider.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Cache\Storage\Adapter\Filesystem as FilesytemCache;
|
||||
|
||||
/**
|
||||
* The configuration provider for the App module
|
||||
*
|
||||
* @see https://docs.zendframework.com/zend-component-installer/
|
||||
*/
|
||||
class ConfigProvider
|
||||
{
|
||||
/**
|
||||
* Returns the configuration array
|
||||
*
|
||||
* To add a bit of a structure, each section is defined in a separate
|
||||
* method which returns an array with its configuration.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __invoke()
|
||||
{
|
||||
return [
|
||||
'dependencies' => $this->getDependencies(),
|
||||
'templates' => $this->getTemplates(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the container dependencies
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
'invokables' => [
|
||||
Action\PingAction::class => Action\PingAction::class,
|
||||
],
|
||||
'factories' => [
|
||||
Action\AvatarAction::class => Action\AvatarFactory::class,
|
||||
Action\HomePageAction::class => Action\HomePageFactory::class,
|
||||
Action\KanbanAction::class => Action\KanbanFactory::class,
|
||||
|
||||
Service\AvatarService::class => Service\AvatarServiceFactory::class,
|
||||
Service\DataCollectorService::class => Service\DataCollectorServiceFactory::class,
|
||||
|
||||
'service.avatarCache' => function(ContainerInterface $container) {
|
||||
$cache = new FilesytemCache();
|
||||
$cache->getOptions()
|
||||
->setFromArray([
|
||||
'ttl' => 28800,
|
||||
'cache_dir' => 'data/cache',
|
||||
]);
|
||||
return $cache;
|
||||
},
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the templates configuration
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTemplates()
|
||||
{
|
||||
return [
|
||||
'paths' => [
|
||||
'app' => ['templates/app'],
|
||||
'error' => ['templates/error'],
|
||||
'layout' => ['templates/layout'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
135
src/App/Entity/JiraAssignee.php
Normal file
135
src/App/Entity/JiraAssignee.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
class JiraAssignee implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $signum;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $avatar;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $active = false;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignum(): string
|
||||
{
|
||||
return $this->signum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $signum
|
||||
* @return JiraAssignee
|
||||
*/
|
||||
public function setSignum(string $signum): JiraAssignee
|
||||
{
|
||||
$this->signum = $signum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return JiraAssignee
|
||||
*/
|
||||
public function setName(string $name): JiraAssignee
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return JiraAssignee
|
||||
*/
|
||||
public function setEmail(string $email): JiraAssignee
|
||||
{
|
||||
$this->email = $email;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAvatar(): string
|
||||
{
|
||||
return $this->avatar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $avatar
|
||||
* @return JiraAssignee
|
||||
*/
|
||||
public function setAvatar(string $avatar): JiraAssignee
|
||||
{
|
||||
$this->avatar = $avatar;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $active
|
||||
* @return JiraAssignee
|
||||
*/
|
||||
public function setActive(bool $active): JiraAssignee
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'signum' => $this->getSignum(),
|
||||
'name' => $this->getName(),
|
||||
'email' => $this->getEmail(),
|
||||
'avatar' => $this->getAvatar(),
|
||||
'active' => $this->isActive(),
|
||||
];
|
||||
}
|
||||
}
|
||||
87
src/App/Entity/JiraIssueType.php
Normal file
87
src/App/Entity/JiraIssueType.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
class JiraIssueType implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $icon;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return JiraIssueType
|
||||
*/
|
||||
public function setName(string $name): JiraIssueType
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @return JiraIssueType
|
||||
*/
|
||||
public function setDescription(string $description): JiraIssueType
|
||||
{
|
||||
$this->description = $description;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon(): string
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $icon
|
||||
* @return JiraIssueType
|
||||
*/
|
||||
public function setIcon(string $icon): JiraIssueType
|
||||
{
|
||||
$this->icon = $icon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'description' => $this->getDescription(),
|
||||
'icon' => $this->getIcon(),
|
||||
];
|
||||
}
|
||||
}
|
||||
63
src/App/Entity/JiraStatus.php
Normal file
63
src/App/Entity/JiraStatus.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
class JiraStatus implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return JiraStatus
|
||||
*/
|
||||
public function setName(string $name): JiraStatus
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getColor(): string
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $color
|
||||
* @return JiraStatus
|
||||
*/
|
||||
public function setColor(string $color): JiraStatus
|
||||
{
|
||||
$this->color = $color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'color' => $this->getColor(),
|
||||
];
|
||||
}
|
||||
}
|
||||
68
src/App/Entity/KanbanBoard.php
Normal file
68
src/App/Entity/KanbanBoard.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class KanbanBoard implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var KanbanEntry[]|ArrayCollection
|
||||
*/
|
||||
private $kanbanEntries;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->kanbanEntries = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return KanbanEntry[]|ArrayCollection
|
||||
*/
|
||||
public function getKanbanEntries(): ArrayCollection
|
||||
{
|
||||
return $this->kanbanEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param KanbanEntry[]|ArrayCollection $kanbanEntries
|
||||
* @return KanbanBoard
|
||||
*/
|
||||
public function setKanbanEntries(ArrayCollection $kanbanEntries): KanbanBoard
|
||||
{
|
||||
$this->kanbanEntries = $kanbanEntries;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param KanbanEntry $kanbanEntry
|
||||
* @return KanbanBoard
|
||||
*/
|
||||
public function addKanbanEntry(KanbanEntry $kanbanEntry): KanbanBoard
|
||||
{
|
||||
if(!$this->kanbanEntries->contains($kanbanEntry)) {
|
||||
$this->kanbanEntries->add($kanbanEntry);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param KanbanEntry $kanbanEntry
|
||||
* @return KanbanBoard
|
||||
*/
|
||||
public function removeKanbanEntry(KanbanEntry $kanbanEntry): KanbanBoard
|
||||
{
|
||||
if($this->kanbanEntries->contains($kanbanEntry)) {
|
||||
$this->kanbanEntries->removeElement($kanbanEntry);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function jsonSerialize()
|
||||
{
|
||||
return $this->kanbanEntries->getValues();
|
||||
}
|
||||
}
|
||||
444
src/App/Entity/KanbanEntry.php
Normal file
444
src/App/Entity/KanbanEntry.php
Normal file
@@ -0,0 +1,444 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class KanbanEntry implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $key;
|
||||
|
||||
// 'fields' below
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $summary;
|
||||
|
||||
/**
|
||||
* @var JiraIssueType
|
||||
*/
|
||||
private $issueType;
|
||||
|
||||
/**
|
||||
* @var JiraStatus
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var JiraAssignee
|
||||
*/
|
||||
private $assignee;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_11226
|
||||
* @var int
|
||||
*/
|
||||
private $prio;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_11225
|
||||
* @var string[]|ArrayCollection
|
||||
*/
|
||||
private $functionalAreas;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10010
|
||||
* @var string
|
||||
*/
|
||||
private $externalId;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10850
|
||||
* @var string
|
||||
*/
|
||||
private $externalLink;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10840
|
||||
* @var string
|
||||
*/
|
||||
private $project;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10844
|
||||
* @var string
|
||||
*/
|
||||
private $mhwebStatus;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10847
|
||||
* @var string
|
||||
*/
|
||||
private $mhwebHot;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10849
|
||||
* @var bool
|
||||
*/
|
||||
private $mhwebExternal = false;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10904
|
||||
* @var string
|
||||
*/
|
||||
private $team;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_11692
|
||||
* @var string
|
||||
*/
|
||||
private $answerCode;
|
||||
|
||||
/**
|
||||
* KanbanEntry constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->functionalAreas = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setId(int $id): KanbanEntry
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setKey(string $key): KanbanEntry
|
||||
{
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSummary(): string
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $summary
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setSummary(string $summary): KanbanEntry
|
||||
{
|
||||
$this->summary = $summary;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JiraIssueType
|
||||
*/
|
||||
public function getIssueType(): ?JiraIssueType
|
||||
{
|
||||
return $this->issueType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JiraIssueType $issueType
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setIssueType(?JiraIssueType $issueType): KanbanEntry
|
||||
{
|
||||
$this->issueType = $issueType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JiraStatus
|
||||
*/
|
||||
public function getStatus(): ?JiraStatus
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JiraStatus $status
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setStatus(?JiraStatus $status): KanbanEntry
|
||||
{
|
||||
$this->status = $status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JiraAssignee
|
||||
*/
|
||||
public function getAssignee(): ?JiraAssignee
|
||||
{
|
||||
return $this->assignee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JiraAssignee $assignee
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setAssignee(?JiraAssignee $assignee): KanbanEntry
|
||||
{
|
||||
$this->assignee = $assignee;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPrio(): ?int
|
||||
{
|
||||
return $this->prio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $prio
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setPrio(?int $prio)
|
||||
{
|
||||
$this->prio = $prio;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]|ArrayCollection
|
||||
*/
|
||||
public function getFunctionalAreas(): ?ArrayCollection
|
||||
{
|
||||
return $this->functionalAreas;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[]|ArrayCollection $functionalAreas
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setFunctionalAreas(ArrayCollection $functionalAreas): KanbanEntry
|
||||
{
|
||||
$this->functionalAreas = $functionalAreas;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $functionalArea
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function addFunctionalArea(string $functionalArea): KanbanEntry
|
||||
{
|
||||
if(!$this->functionalAreas->contains($functionalArea)) {
|
||||
$this->functionalAreas->add($functionalArea);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $functionalArea
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function removeFunctionalArea(string $functionalArea): KanbanEntry
|
||||
{
|
||||
if($this->functionalAreas->contains($functionalArea)) {
|
||||
$this->functionalAreas->removeElement($functionalArea);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalId(): ?string
|
||||
{
|
||||
return $this->externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $externalId
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setExternalId(?string $externalId): KanbanEntry
|
||||
{
|
||||
$this->externalId = $externalId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalLink(): ?string
|
||||
{
|
||||
return $this->externalLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $externalLink
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setExternalLink(?string $externalLink): KanbanEntry
|
||||
{
|
||||
$this->externalLink = $externalLink;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProject(): ?string
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $project
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setProject(?string $project): KanbanEntry
|
||||
{
|
||||
$this->project = $project;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMhwebStatus(): ?string
|
||||
{
|
||||
return $this->mhwebStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mhwebStatus
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setMhwebStatus(?string $mhwebStatus): KanbanEntry
|
||||
{
|
||||
$this->mhwebStatus = $mhwebStatus;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getMhwebHot(): ?bool
|
||||
{
|
||||
return $this->mhwebHot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $mhwebHot
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setMhwebHot(?bool $mhwebHot): KanbanEntry
|
||||
{
|
||||
$this->mhwebHot = $mhwebHot;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getMhwebExternal(): ?bool
|
||||
{
|
||||
return $this->mhwebExternal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $mhwebExternal
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setMhwebExternal(?bool $mhwebExternal): KanbanEntry
|
||||
{
|
||||
$this->mhwebExternal = $mhwebExternal;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTeam(): ?string
|
||||
{
|
||||
return $this->team;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $team
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setTeam(?string $team): KanbanEntry
|
||||
{
|
||||
$this->team = $team;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAnswerCode(): ?string
|
||||
{
|
||||
return $this->answerCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $answerCode
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setAnswerCode(?string $answerCode): KanbanEntry
|
||||
{
|
||||
$this->answerCode = $answerCode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'key' => $this->getKey(),
|
||||
'summary' => $this->getSummary(),
|
||||
'issueType' => $this->getIssueType(),
|
||||
'status' => $this->getStatus(),
|
||||
'assignee' => $this->getAssignee(),
|
||||
'prio' => $this->getPrio(),
|
||||
'functionalArea' => $this->getFunctionalAreas()->getValues(),
|
||||
'externalId' => $this->getExternalId(),
|
||||
'externalLink' => $this->getExternalLink(),
|
||||
'project' => $this->getProject(),
|
||||
'mhwebStatus' => $this->getMhwebStatus(),
|
||||
'mhwebHot' => $this->getMhwebHot(),
|
||||
'mhwebExternal' => $this->getMhwebExternal(),
|
||||
'team' => $this->getTeam(),
|
||||
'answerCode' => $this->getAnswerCode(),
|
||||
];
|
||||
}
|
||||
}
|
||||
86
src/App/Service/AvatarService.php
Normal file
86
src/App/Service/AvatarService.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Zend\Cache\Storage\StorageInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class AvatarService
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @var RouterInterface
|
||||
*/
|
||||
private $router;
|
||||
|
||||
/**
|
||||
* @var StorageInterface
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* JiraClientService constructor.
|
||||
* @param Client $client
|
||||
* @param Config $config
|
||||
* @param RouterInterface $router
|
||||
*/
|
||||
public function __construct(Client $client, Config $config, RouterInterface $router, StorageInterface $cache)
|
||||
{
|
||||
$this->httpClient = $client;
|
||||
$this->config = $config;
|
||||
$this->router = $router;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $jiraAvatarUrl
|
||||
* @param string $signum
|
||||
* @return string
|
||||
*/
|
||||
public function getJiraAvatarUrl(string $jiraAvatarUrl, string $signum): string
|
||||
{
|
||||
if (!$this->cache->hasItem($signum)) {
|
||||
$user = $this->config->get('jira.user');
|
||||
$password = $this->config->get('jira.password');
|
||||
|
||||
$response = $this->httpClient
|
||||
->setAuth($user, $password)
|
||||
->setUri($jiraAvatarUrl)
|
||||
->send();
|
||||
|
||||
if (!$response->isSuccess()) {
|
||||
throw new \UnexpectedValueException("Bad JIRA result", $response->getStatusCode());
|
||||
}
|
||||
|
||||
$this->cache->setItem($signum, $response->getBody());
|
||||
}
|
||||
|
||||
return $this->router->generateUri('user.avatar', [
|
||||
'signum' => $signum,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $signum
|
||||
* @return string
|
||||
*/
|
||||
public function getAvatarData(string $signum): string
|
||||
{
|
||||
if (!$this->cache->hasItem($signum)) {
|
||||
throw new \UnexpectedValueException("Missing avatar", 404);
|
||||
}
|
||||
|
||||
return $this->cache->getItem($signum);
|
||||
}
|
||||
}
|
||||
26
src/App/Service/AvatarServiceFactory.php
Normal file
26
src/App/Service/AvatarServiceFactory.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class AvatarServiceFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$router = $container->get(RouterInterface::class);
|
||||
$configArray = $container->get('config');
|
||||
$httpClient = new Client();
|
||||
$httpClient->getAdapter()->setOptions([
|
||||
'timeout' => 60,
|
||||
]);
|
||||
|
||||
$cache = $container->get('service.avatarCache');
|
||||
|
||||
$config = new Config($configArray['app.config']);
|
||||
return new AvatarService($httpClient, $config, $router, $cache);
|
||||
}
|
||||
}
|
||||
172
src/App/Service/DataCollectorService.php
Normal file
172
src/App/Service/DataCollectorService.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\JiraAssignee;
|
||||
use App\Entity\JiraIssueType;
|
||||
use App\Entity\JiraStatus;
|
||||
use App\Entity\KanbanBoard;
|
||||
use App\Entity\KanbanEntry;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
use Zend\Json\Decoder;
|
||||
use Zend\Json\Json;
|
||||
|
||||
class DataCollectorService
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @var AvatarService
|
||||
*/
|
||||
private $avatarService;
|
||||
|
||||
/**
|
||||
* JiraClientService constructor.
|
||||
* @param Client $client
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Client $client, Config $config, AvatarService $avatarService)
|
||||
{
|
||||
$this->avatarService = $avatarService;
|
||||
$this->httpClient = $client;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return KanbanBoard
|
||||
*/
|
||||
public function getKanbanBoard(): KanbanBoard
|
||||
{
|
||||
$user = $this->config->get('jira.user');
|
||||
$password = $this->config->get('jira.password');
|
||||
/** @var Config $kanbanBoardUriParams */
|
||||
$kanbanBoardUriParams = $this->config->get('url.jiraKanbanBoard');
|
||||
|
||||
$kanbanBoardUri = sprintf(
|
||||
$kanbanBoardUriParams['baseUrl'],
|
||||
$kanbanBoardUriParams['filterId'],
|
||||
implode(",", $kanbanBoardUriParams['fields']->toArray())
|
||||
);
|
||||
|
||||
$response = $this->httpClient
|
||||
->setAuth($user, $password)
|
||||
->setUri($kanbanBoardUri)
|
||||
->send();
|
||||
|
||||
if(!$response->isSuccess()) {
|
||||
throw new \UnexpectedValueException("Bad JIRA result", $response->getStatusCode());
|
||||
}
|
||||
|
||||
$parsedJsonData = Decoder::decode($response->getBody(), Json::TYPE_ARRAY);
|
||||
return $this->hydrateKanbanBoard($parsedJsonData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $parsedJsonData
|
||||
* @return KanbanBoard
|
||||
* @todo check if avatar has to be locally cached
|
||||
*/
|
||||
private function hydrateKanbanBoard($parsedJsonData): KanbanBoard
|
||||
{
|
||||
$kanbanBoard = new KanbanBoard();
|
||||
|
||||
foreach($parsedJsonData['issues'] as $jsonIssue) {
|
||||
$kanbanEntry = new KanbanEntry();
|
||||
$kanbanEntry->setId(intval($jsonIssue['id']))
|
||||
->setKey($jsonIssue['key'])
|
||||
->setSummary($jsonIssue['fields']['summary'])
|
||||
->setExternalLink($jsonIssue['fields']['customfield_10850'])
|
||||
->setMhwebStatus($jsonIssue['fields']['customfield_10844'])
|
||||
->setAnswerCode($jsonIssue['fields']['customfield_11692'])
|
||||
;
|
||||
|
||||
// externalId : customfield_10010
|
||||
if(isset($jsonIssue['fields']['customfield_10010'])) {
|
||||
$kanbanEntry->setPrio(intval($jsonIssue['fields']['customfield_10010']));
|
||||
}
|
||||
|
||||
// prio : customfield_10840
|
||||
if(isset($jsonIssue['fields']['customfield_11226'])) {
|
||||
$kanbanEntry->setPrio($jsonIssue['fields']['customfield_11226']);
|
||||
}
|
||||
|
||||
// functional area : customfield_11225
|
||||
if(isset($jsonIssue['fields']['customfield_11225'])) {
|
||||
foreach ($jsonIssue['fields']['customfield_11225'] as $functionalArea) {
|
||||
$kanbanEntry->addFunctionalArea($functionalArea['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// project : customfield_10840
|
||||
if(isset($jsonIssue['fields']['customfield_10840'])) {
|
||||
$kanbanEntry->setProject($jsonIssue['fields']['customfield_10840']['value']);
|
||||
}
|
||||
|
||||
// mhweb hot : customfield_10847
|
||||
if(isset($jsonIssue['fields']['customfield_10847'])) {
|
||||
$boolVal = $jsonIssue['fields']['customfield_10847'][0]['value'] == 'yes';
|
||||
$kanbanEntry->setMhwebHot($boolVal);
|
||||
}
|
||||
|
||||
// mhweb external : customfield_10849
|
||||
if(isset($jsonIssue['fields']['customfield_10849'])) {
|
||||
$boolVal = $jsonIssue['fields']['customfield_10849'][0]['value'] == 'yes';
|
||||
$kanbanEntry->setMhwebExternal($boolVal);
|
||||
}
|
||||
|
||||
// team : customfield_10904
|
||||
if(isset($jsonIssue['fields']['customfield_10904'])) {
|
||||
$kanbanEntry->setTeam($jsonIssue['fields']['customfield_10904']['value']);
|
||||
}
|
||||
|
||||
// jira status
|
||||
$jiraStatus = new JiraStatus();
|
||||
$jiraStatus->setName($jsonIssue['fields']['status']['name'])
|
||||
->setColor($jsonIssue['fields']['status']['statusCategory']['colorName']);
|
||||
$kanbanEntry->setStatus($jiraStatus);
|
||||
|
||||
// assignee
|
||||
if($jsonIssue['fields']['assignee']) {
|
||||
$avatarUrl = $this->avatarService->getJiraAvatarUrl(
|
||||
$jsonIssue['fields']['assignee']['avatarUrls']['48x48'],
|
||||
$jsonIssue['fields']['assignee']['key']
|
||||
);
|
||||
|
||||
$jiraAssignee = new JiraAssignee();
|
||||
$jiraAssignee->setName($jsonIssue['fields']['assignee']['displayName'])
|
||||
->setSignum($jsonIssue['fields']['assignee']['key'])
|
||||
->setEmail(strtolower($jsonIssue['fields']['assignee']['emailAddress']))
|
||||
->setAvatar($avatarUrl)
|
||||
->setActive($jsonIssue['fields']['assignee']['active']);
|
||||
|
||||
$kanbanEntry->setAssignee($jiraAssignee);
|
||||
unset($jiraAssignee);
|
||||
}
|
||||
|
||||
// issue type
|
||||
if($jsonIssue['fields']['issuetype']) {
|
||||
$jiraIssueType = new JiraIssueType();
|
||||
$jiraIssueType->setName($jsonIssue['fields']['issuetype']['name'])
|
||||
->setDescription($jsonIssue['fields']['issuetype']['description'])
|
||||
->setIcon($jsonIssue['fields']['issuetype']['iconUrl']);
|
||||
|
||||
$kanbanEntry->setIssueType($jiraIssueType);
|
||||
unset($jiraIssueType);
|
||||
}
|
||||
|
||||
$kanbanBoard->addKanbanEntry($kanbanEntry);
|
||||
unset($kanbanEntry);
|
||||
}
|
||||
|
||||
return $kanbanBoard;
|
||||
}
|
||||
}
|
||||
22
src/App/Service/DataCollectorServiceFactory.php
Normal file
22
src/App/Service/DataCollectorServiceFactory.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class DataCollectorServiceFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$configArray = $container->get('config');
|
||||
$httpClient = new Client();
|
||||
$httpClient->getAdapter()->setOptions([
|
||||
'timeout' => 60,
|
||||
]);
|
||||
$config = new Config($configArray['app.config']);
|
||||
$avatarService = $container->get(AvatarService::class);
|
||||
return new DataCollectorService($httpClient, $config, $avatarService);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user