Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't extract from KnpMenu service #502

Open
picks44 opened this issue Oct 23, 2018 · 0 comments
Open

Can't extract from KnpMenu service #502

picks44 opened this issue Oct 23, 2018 · 0 comments

Comments

@picks44
Copy link

picks44 commented Oct 23, 2018

Q A
Bundle version 1.4.3
Symfony version 3.4.17

I'm extracting all my translatable items as well as route s perfectly, but not the ones in my Menu.php service that builds a KnpMenuBundle object... It's working fine in one of my project under SF 2.8 but not today... Any clue?

My config

jms_translation:
    configs:
        app:
            dirs: ["%kernel.root_dir%/Resources/views", "%kernel.root_dir%/../src"]
            output_dir: "%kernel.root_dir%/Resources/translations"
            excluded_names: ["*TestCase.php", "*Test.php"]
            excluded_dirs: [cache, data, logs]
            extractors: [jms_i18n_routing]

And my Menu.php (located in src/AppBundle/Service)

<?php

namespace AppBundle\Service;

use Knp\Menu\FactoryInterface;

/**
 * Class Menu
 * @package AppBundle\Menu
 */
class Menu
{
    /**
     * @var FactoryInterface
     */
    private $factory;

    /**
     * Menu constructor.
     * @param FactoryInterface $factory
     */
    public function __construct(FactoryInterface $factory)
    {
        $this->factory = $factory;
    }

    /**
     * @return \Knp\Menu\ItemInterface
     * @throws \InvalidArgumentException
     */
    public function createMainMenu()
    {
        $menu = $this->factory->createItem('root');
        $menu->setChildrenAttribute('class', 'navbar-nav ml-auto');

        $menu->addChild('Accueil', [
            'route' => 'index'
        ])->setAttribute('class', 'nav-item')->setExtra('translation_domain', 'menu');
        $menu['Accueil']->setLinkAttribute('class', 'nav-link');

        $menu->addChild('Projets', [
            'route' => 'projects',
            'extras' => [
                'routes' => [
                    [
                        'route' => 'project'
                    ],
                ],
            ],
        ])->setAttribute('class', 'nav-item')->setExtra('translation_domain', 'menu');
        $menu['Projets']->setLinkAttribute('class', 'nav-link');

        $menu->addChild('Contact', [
            'route' => 'contact'
        ])->setAttribute('class', 'nav-item')->setExtra('translation_domain', 'menu');
        $menu['Contact']->setLinkAttribute('class', 'nav-link');

        return $menu;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant