Skip to content

Commit

Permalink
Adds translations to navigation bar
Browse files Browse the repository at this point in the history
  • Loading branch information
moay committed Jan 24, 2020
1 parent 08a9850 commit b09aed3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Frontend/Twig/Utility/NavigationBarBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use LoxBerryPoppins\Frontend\Navigation\NavigationConfigurationParser;
use LoxBerryPoppins\Frontend\Navigation\UrlBuilder;
use LoxBerryPoppins\Frontend\Routing\RouteMatcher;
use LoxBerryPoppins\Frontend\Twig\Extensions\Translations;
use Symfony\Component\HttpFoundation\Request;

/**
Expand All @@ -21,22 +22,28 @@ class NavigationBarBuilder
/** @var UrlBuilder */
private $urlBuilder;

/** @var Translations */
private $translations;

/**
* NavigationBarBuilder constructor.
*
* @param NavigationConfigurationParser $navigationConfigurationParser
* @param RouteMatcher $routeMatcher
* @param UrlBuilder $urlBuilder
* @param Translations $translations
*/
public function __construct(
NavigationConfigurationParser $navigationConfigurationParser,
RouteMatcher $routeMatcher,
UrlBuilder $urlBuilder
UrlBuilder $urlBuilder,
Translations $translations
) {
$this->navigationConfiguration = $navigationConfigurationParser->getConfiguration();
$this->request = Request::createFromGlobals();
$this->routeMatcher = $routeMatcher;
$this->urlBuilder = $urlBuilder;
$this->translations = $translations;
}

/**
Expand All @@ -60,7 +67,7 @@ public function getNavigationBarHtml(): string
array_key_exists('target', $navigationItem) ? 'target="'.$navigationItem['target'].'"' : '',
$this->routeMatcher->isCurrentMatchedRoute($navigationItem['route'], false) ?
'class="ui-btn-active"' : '',
$navigationItem['title'] ?? $index
$this->translations->translate($navigationItem['title'] ?? $index)
);
}
$navigationBar .= '</ul></div>';
Expand Down

0 comments on commit b09aed3

Please sign in to comment.