Skip to content

Commit

Permalink
Merge branch '5.9' into 5.10
Browse files Browse the repository at this point in the history
* 5.9:
  [NodeBundle] Improve performance of NodeMenu class
  • Loading branch information
acrobat committed Jan 10, 2022
2 parents 2d68ca4 + e5406b0 commit 2418821
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/Kunstmaan/NodeBundle/Helper/NodeMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,32 +241,33 @@ function (NodeMenuItem $entry) use ($includeHiddenFromNav) {
*/
public function getBreadCrumb()
{
$this->init();
if (!\is_array($this->breadCrumb)) {
$this->breadCrumb = [];

/* @var NodeRepository $repo */
$repo = $this->em->getRepository(Node::class);

// Generate breadcrumb MenuItems - fetch *all* languages so you can link translations if needed
$parentNodes = $repo->getAllParents($this->currentNode);
$parentNodeMenuItem = null;
/* @var Node $parentNode */
foreach ($parentNodes as $parentNode) {
$nodeTranslation = $parentNode->getNodeTranslation(
$this->locale,
$this->includeOffline
if (\is_array($this->breadCrumb)) {
return $this->breadCrumb;
}

$this->breadCrumb = [];

/* @var NodeRepository $repo */
$repo = $this->em->getRepository(Node::class);

// Generate breadcrumb MenuItems - fetch *all* languages so you can link translations if needed
$parentNodes = $repo->getAllParents($this->currentNode);
$parentNodeMenuItem = null;
/* @var Node $parentNode */
foreach ($parentNodes as $parentNode) {
$nodeTranslation = $parentNode->getNodeTranslation(
$this->locale,
$this->includeOffline
);
if (!\is_null($nodeTranslation)) {
$nodeMenuItem = new NodeMenuItem(
$parentNode,
$nodeTranslation,
$parentNodeMenuItem,
$this
);
if (!\is_null($nodeTranslation)) {
$nodeMenuItem = new NodeMenuItem(
$parentNode,
$nodeTranslation,
$parentNodeMenuItem,
$this
);
$this->breadCrumb[] = $nodeMenuItem;
$parentNodeMenuItem = $nodeMenuItem;
}
$this->breadCrumb[] = $nodeMenuItem;
$parentNodeMenuItem = $nodeMenuItem;
}
}

Expand All @@ -278,7 +279,6 @@ public function getBreadCrumb()
*/
public function getCurrent()
{
$this->init();
$breadCrumb = $this->getBreadCrumb();
if (\count($breadCrumb) > 0) {
return $breadCrumb[\count($breadCrumb) - 1];
Expand Down

0 comments on commit 2418821

Please sign in to comment.