Skip to content

Commit

Permalink
[!!!][TASK] Use ParameterBagInterface to get parameter (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed Feb 10, 2022
1 parent 407f56f commit 8f0b612
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 59 deletions.
3 changes: 0 additions & 3 deletions src/Menu/DividerItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

final class DividerItem extends MenuItem
{
/**
* @param FactoryInterface $factory
*/
public function __construct(FactoryInterface $factory)
{
parent::__construct('divider' . uniqid(), $factory);
Expand Down
69 changes: 13 additions & 56 deletions src/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Knp\Menu\ItemInterface;
use Knp\Menu\Matcher\MatcherInterface;
use Knp\Menu\MenuFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -24,87 +24,44 @@
*/
class MenuBuilder
{
/**
* @var ContainerInterface
*/
public $container;
public ParameterBagInterface $parameters;
public MenuFactory $factory;
public MatcherInterface $matcher;
public AuthorizationCheckerInterface $authorizationChecker;
public TokenStorageInterface $tokenStorage;
public TranslatorInterface $translator;

/**
* @var MenuFactory
*/
public $factory;

/**
* @var MatcherInterface
*/
public $matcher;

/**
* @var AuthorizationCheckerInterface
*/
public $authorizationChecker;

/**
* @var TokenStorageInterface
*/
public $tokenStorage;

/**
* @var TranslatorInterface
*/
public $translator;

/**
* @param ContainerInterface $container
* @param FactoryInterface $factory
* @param MatcherInterface $matcher
* @param AuthorizationCheckerInterface $authorizationChecker
* @param TokenStorageInterface $tokenStorage
* @param TranslatorInterface $translator
*/
public function __construct(
ContainerInterface $container,
ParameterBagInterface $parameters,
FactoryInterface $factory,
MatcherInterface $matcher,
AuthorizationCheckerInterface $authorizationChecker,
TokenStorageInterface $tokenStorage,
TranslatorInterface $translator
) {
$this->container = $container;
$this->parameters = $parameters;
$this->factory = $factory;
$this->matcher = $matcher;
$this->authorizationChecker = $authorizationChecker;
$this->tokenStorage = $tokenStorage;
$this->translator = $translator;
}

/**
* @param array $options
* @return \Knp\Menu\ItemInterface|\Knp\Menu\MenuItem
*/
public function mainDefault(array $options)
public function mainDefault(array $options): ItemInterface
{
$menu = $this->factory->createItem('root');
return $menu;
}

/**
* @param array $options
* @return \Knp\Menu\ItemInterface|\Knp\Menu\MenuItem
*/
public function mainProfile(array $options)
public function mainProfile(array $options): ItemInterface
{
$menu = $this->factory->createItem('root');
return $menu;
}

/**
* @param array $options
* @return \Knp\Menu\ItemInterface|\Knp\Menu\MenuItem
*/
public function mainFooter(array $options)
public function mainFooter(array $options): ItemInterface
{
$config = $this->container->getParameter('t3g.template.config');
$config = $this->parameters->get('t3g.template.config');
$menu = $this->factory->createItem('root');
if (!empty($config['application']['routes']['privacy'])) {
$menu->addChild(
Expand Down

0 comments on commit 8f0b612

Please sign in to comment.