fix tag query to show all tags of an item, even if not included in query (#810)

This commit is contained in:
Kevin Papst
2019-05-25 16:27:01 +02:00
committed by GitHub
parent 46905e9504
commit d18019159b
3 changed files with 23 additions and 15 deletions

View File

@@ -10,6 +10,7 @@
namespace App\Repository\Query;
use App\Entity\Activity;
use App\Entity\Tag;
use App\Entity\User;
use App\Form\Model\DateRange;
@@ -216,9 +217,22 @@ class TimesheetQuery extends ActivityQuery
/**
* @return iterable
*/
public function getTags()
public function getTags($allowUnknown = false)
{
return $this->tags;
if (empty($this->tags)) {
return [];
}
$result = [];
foreach ($this->tags as $tag) {
if (!$allowUnknown && $tag instanceof Tag && null === $tag->getId()) {
continue;
}
$result[] = $tag;
}
return $result;
}
/**
@@ -231,12 +245,4 @@ class TimesheetQuery extends ActivityQuery
return $this;
}
/**
* @return bool
*/
public function hasTags()
{
return !empty($this->tags) && count($this->tags) > 0;
}
}