Skip to content

Commit

Permalink
reduce queries in tags get children by id
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 committed Jul 24, 2024
1 parent 33a7bef commit 201f3cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Controller/Admin/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ public function treeGetChildrenByIdAction(Request $request): JsonResponse

protected function convertTagToArray(Tag $tag, bool $showSelection, array $assignedTagIds, bool $loadChildren = false, bool $recursiveChildren = false): array
{
$hasChildren = $tag->hasChildren();

$tagArray = [
'id' => $tag->getId(),
'text' => $tag->getName(),
'path' => $tag->getNamePath(),
'expandable' => $tag->hasChildren(),
'leaf' => !$tag->hasChildren(),
'expandable' => $hasChildren,
'leaf' => !$hasChildren,
'iconCls' => 'pimcore_icon_element_tags',
'qtipCfg' => [
'title' => 'ID: ' . $tag->getId(),
Expand All @@ -170,7 +172,7 @@ protected function convertTagToArray(Tag $tag, bool $showSelection, array $assig
$tagArray['checked'] = isset($assignedTagIds[$tag->getId()]);
}

if ($loadChildren) {
if ($hasChildren && $loadChildren) {
$children = $tag->getChildren();
$loadChildren = $recursiveChildren;
foreach ($children as $child) {
Expand Down

0 comments on commit 201f3cd

Please sign in to comment.