2017-07-31 15:50:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
|
|
|
|
|
class KanbanBoard implements \JsonSerializable
|
|
|
|
|
{
|
2017-08-15 16:13:23 +02:00
|
|
|
const PRIO_TRIVIAL = 0;
|
|
|
|
|
const PRIO_MINOR = 1;
|
|
|
|
|
const PRIO_MAJOR = 2;
|
|
|
|
|
const PRIO_CRITICAL = 3;
|
|
|
|
|
const PRIO_BLOCKER = 4;
|
|
|
|
|
|
|
|
|
|
private $priorityMap = [
|
|
|
|
|
'Trivial' => self::PRIO_TRIVIAL,
|
|
|
|
|
'Minor' => self::PRIO_MINOR,
|
|
|
|
|
'Major' => self::PRIO_MAJOR,
|
|
|
|
|
'Critical' => self::PRIO_CRITICAL,
|
|
|
|
|
'Blocker' => self::PRIO_BLOCKER,
|
|
|
|
|
];
|
|
|
|
|
|
2017-07-31 15:50:48 +02:00
|
|
|
/**
|
|
|
|
|
* @var KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
2017-08-02 18:49:50 +02:00
|
|
|
private $inbox;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
|
|
|
|
private $inProgress;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
|
|
|
|
private $verification;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
|
|
|
|
private $done;
|
2017-07-31 15:50:48 +02:00
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2017-08-02 18:49:50 +02:00
|
|
|
$this->inbox = new ArrayCollection();
|
|
|
|
|
$this->inProgress = new ArrayCollection();
|
|
|
|
|
$this->verification = new ArrayCollection();
|
|
|
|
|
$this->done = new ArrayCollection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
|
|
|
|
public function getInbox(): ArrayCollection
|
|
|
|
|
{
|
|
|
|
|
return $this->inbox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry[]|ArrayCollection $inbox
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function setInbox(ArrayCollection $inbox): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
$this->inbox = $inbox;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry $inbox
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function addInbox(KanbanEntry $inbox): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
if (!$this->inbox->contains($inbox)) {
|
|
|
|
|
$this->inbox->add($inbox);
|
|
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry $inbox
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function removeInbox(KanbanEntry $inbox): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
if ($this->inbox->contains($inbox)) {
|
|
|
|
|
$this->inbox->removeElement($inbox);
|
|
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
|
|
|
|
public function getInProgress(): ArrayCollection
|
|
|
|
|
{
|
|
|
|
|
return $this->inProgress;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry[]|ArrayCollection $inProgress
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function setInProgress(ArrayCollection $inProgress): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
$this->inProgress = $inProgress;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry $inProgress
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function addInProgress(KanbanEntry $inProgress): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
if (!$this->inProgress->contains($inProgress)) {
|
|
|
|
|
$this->inProgress->add($inProgress);
|
|
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry $inProgress
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function removeInProgress(KanbanEntry $inProgress): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
if ($this->inProgress->contains($inProgress)) {
|
|
|
|
|
$this->inProgress->removeElement($inProgress);
|
|
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
|
|
|
|
public function getVerification(): ArrayCollection
|
|
|
|
|
{
|
|
|
|
|
return $this->verification;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry[]|ArrayCollection $verification
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function setVerification(ArrayCollection $verification): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
$this->verification = $verification;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry $verification
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function addVerification(KanbanEntry $verification): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
if (!$this->verification->contains($verification)) {
|
|
|
|
|
$this->verification->add($verification);
|
|
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry $verification
|
|
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
|
|
|
|
public function removeVerification(KanbanEntry $verification): KanbanBoard
|
|
|
|
|
{
|
|
|
|
|
if ($this->verification->contains($verification)) {
|
|
|
|
|
$this->verification->removeElement($verification);
|
|
|
|
|
}
|
|
|
|
|
return $this;
|
2017-07-31 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return KanbanEntry[]|ArrayCollection
|
|
|
|
|
*/
|
2017-08-02 18:49:50 +02:00
|
|
|
public function getDone(): ArrayCollection
|
2017-07-31 15:50:48 +02:00
|
|
|
{
|
2017-08-02 18:49:50 +02:00
|
|
|
return $this->done;
|
2017-07-31 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-02 18:49:50 +02:00
|
|
|
* @param KanbanEntry[]|ArrayCollection $verification
|
2017-07-31 15:50:48 +02:00
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
2017-08-02 18:49:50 +02:00
|
|
|
public function setDone(ArrayCollection $verification): KanbanBoard
|
2017-07-31 15:50:48 +02:00
|
|
|
{
|
2017-08-02 18:49:50 +02:00
|
|
|
$this->done = $verification;
|
2017-07-31 15:50:48 +02:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-02 18:49:50 +02:00
|
|
|
* @param KanbanEntry $verification
|
2017-07-31 15:50:48 +02:00
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
2017-08-02 18:49:50 +02:00
|
|
|
public function addDone(KanbanEntry $verification): KanbanBoard
|
2017-07-31 15:50:48 +02:00
|
|
|
{
|
2017-08-02 18:49:50 +02:00
|
|
|
if (!$this->done->contains($verification)) {
|
|
|
|
|
$this->done->add($verification);
|
2017-07-31 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-02 18:49:50 +02:00
|
|
|
* @param KanbanEntry $verification
|
2017-07-31 15:50:48 +02:00
|
|
|
* @return KanbanBoard
|
|
|
|
|
*/
|
2017-08-02 18:49:50 +02:00
|
|
|
public function removeDone(KanbanEntry $verification): KanbanBoard
|
2017-07-31 15:50:48 +02:00
|
|
|
{
|
2017-08-02 18:49:50 +02:00
|
|
|
if ($this->done->contains($verification)) {
|
|
|
|
|
$this->done->removeElement($verification);
|
2017-07-31 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 16:13:23 +02:00
|
|
|
/**
|
|
|
|
|
* @param KanbanEntry[] $toSort
|
|
|
|
|
* @return KanbanEntry[]
|
|
|
|
|
*/
|
|
|
|
|
private function prioSort(array $toSort): array
|
|
|
|
|
{
|
|
|
|
|
usort($toSort, function(KanbanEntry $a, KanbanEntry $b){
|
|
|
|
|
return $this->priorityMap[$b->getIssuePriority()] <=> $this->priorityMap[$a->getIssuePriority()];
|
|
|
|
|
});
|
|
|
|
|
return $toSort;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-31 15:50:48 +02:00
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
function jsonSerialize()
|
|
|
|
|
{
|
2017-08-02 18:49:50 +02:00
|
|
|
return [
|
2017-08-15 16:13:23 +02:00
|
|
|
'inbox' => $this->prioSort($this->inbox->getValues()),
|
|
|
|
|
'inProgress' => $this->prioSort($this->inProgress->getValues()),
|
|
|
|
|
'verification' => $this->prioSort($this->verification->getValues()),
|
|
|
|
|
'done' => $this->prioSort($this->done->getValues()),
|
2017-08-02 18:49:50 +02:00
|
|
|
];
|
2017-07-31 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
}
|