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

Autocomplete route name in php and twig not working since Symfony 2.8 #669

Closed
j4k4 opened this issue Jan 21, 2016 · 8 comments
Closed

Autocomplete route name in php and twig not working since Symfony 2.8 #669

j4k4 opened this issue Jan 21, 2016 · 8 comments
Labels

Comments

@j4k4
Copy link

j4k4 commented Jan 21, 2016

Since the update to symfony 2.8 the autocomplete of routes doesn't work anymore..
The format appDevUrlGenerator.php file has changed, i think..
Anyone else has this problem?

@acidjames
Copy link

Hi tarsonius, i still have route autocomplete working on 2.8.2 but twig files and controller functions are no longer connected :(

@j4k4
Copy link
Author

j4k4 commented Jan 25, 2016

@acidjames
What's the format of your appDevUrlGenerator.php? This is the file, where the routes are extracted from?
Mine looks like:

class appDevUrlGenerator extends Symfony\Component\Routing\Generator\UrlGenerator
{
    private static $declaredRoutes;

    /**
     * Constructor.
     */
    public function __construct(RequestContext $context, LoggerInterface $logger = null)
    {
        $this->context = $context;
        $this->logger = $logger;
        if (null === self::$declaredRoutes) {
            self::$declaredRoutes = array(
        '_wdt' => array (  0 =>   array (    0 => 'token',  ),  1 =>   array (    '_controller' => 'web_profiler.controller.profiler:toolbarAction',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'variable',      1 => '/',      2 => '[^/]++',      3 => 'token',    ),    1 =>     array (      0 => 'text',      1 => '/_wdt',    ),  ),  4 =>   array (  ),  5 =>   array (  ),),
        '_profiler_home' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'web_profiler.controller.profiler:homeAction',  ),  2 =>   array (  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/_profiler/',    ),  ),  4 =>   array (  ),  5 =>   array (  ),),

@acidjames
Copy link

@Tarsonius the file structure is the same as yours.

Finally, i've rebuilt all the cache and seems to work + there has been an update this morning for the plugin :)

@j4k4
Copy link
Author

j4k4 commented Jan 25, 2016

I've updated to the latest version this morning. Still doesn't work for me..
It says 'Missing route..' in controllers and twig templates..

@gharlan
Copy link

gharlan commented Jan 27, 2016

Same issue here. it works in a 2.7 project, but not in 2.8.

The format appDevUrlGenerator.php file has changed

the assignment has moved from property declaration to constructor. Don't know if this is the reason.

@j4k4
Copy link
Author

j4k4 commented Jan 27, 2016

Yes, i think, that's the problem..
The getRoutesInsideUrlGeneratorFile method in the RouteHelper class extracts the routes as follows:

if(new Symfony2InterfacesUtil().isInstanceOf(phpClass, "\\Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface")) {
                for(Field field: phpClass.getFields()) {
                    if(field.getName().equals("declaredRoutes")) {
                        PsiElement defaultValue = field.getDefaultValue();
                        if(defaultValue instanceof ArrayCreationExpression) {
                            Iterable<ArrayHashElement> arrayHashElements = ((ArrayCreationExpression) defaultValue).getHashElements();
                            for(ArrayHashElement arrayHashElement: arrayHashElements) {

Since the update to 2.8, the default value is empty, so there are no routes for the autocomplete feature..
I'm not sure how to get it working again..

@Haehnchen
Copy link
Owner

thx for some debugging of what changed in detail. also supporting constructor now

@j4k4
Copy link
Author

j4k4 commented Jan 28, 2016

We have to thank you for the fix.. :)

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

No branches or pull requests

4 participants