0
votes

I just created a new bundle, and I got an error 500 in some case. I gave the maximum information which can be used below. Thanks for your help i'm lost in the darkest fog I've ever seen right now^^

First of all, I have a page /adm_module where i can find links to several backend administrations. It works fine, but i got an error if one of those backend links are the one of my new bundle module.

You can see the logs that happens with that error 500 on that page.

[2017-08-03 16:06:36] request.INFO: Matched route "adm_module". {"route_parameters":{"_controller":"Bva\CoreBundle\Controller\Backend\ModuleController::indexAction","_route":"adm_module"},"request_uri":"http://myshop.localhost/bo/adm_module/"} []

[2017-08-03 16:06:37] security.INFO: Attempting SimplePreAuthentication. {"key":"secured_area","authenticator":"Bva\CoreBundle\Security\WeblinkAuthenticator"} []

[2017-08-03 16:06:47] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "touring" as such route does not exist.") in "BvaCoreBundle:Backend\Module:index.html.twig" at line 64." at C:\wamp64\www\portail_enqueteur\vendor\twig\twig\lib\Twig\Template.php line 222 {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\ "Unable to generate a URL for the named route \"touring\" as such route does not exist.\") in \"BvaCoreBundle:Backend\Module:index.html.twig\" at line 64. at C:\wamp64\www\portail_enqueteur\vendor\twig\twig\lib\Twig\Template.php:222,Symfony\Component\Routing\Exception\RouteNotFoundException(code: 0): Unable to generate a URL for the named route \"touring\" as such route does not exist. at C:\wamp64\www\portail_enqueteur\var\cache\prod\appProdProjectContainerUrlGenerator.php:451)"} []

This is my CoreBundle/routing.yml

BvaCoreBundle_adm_module:
resource: "@BvaCoreBundle/Resources/config/routing/Backend/module.yml"
prefix:   /adm_module

And the module.yml

adm_module:
pattern:  /
defaults: { _controller: "BvaCoreBundle:Backend/Module:index" }

The indexController is just getting the data and calling the index view you can see in the logs

index.html.twig

This is the line 64 where i get the error

<a target="_blank" href="{{ path(instance.module.type, {'instance': instance.id}) }}" class="min-button"><span class="icon-eye-view" title="See in preprod"></span></a>

So I understand the log...he try to fing my touring road in routing but he can't succeed.

Here is what I have in my app/backend/routing.yml

BvaLinkBundle_backend:
   resource: "@BvaLinkBundle/Resources/config/routing/backend.yml"
   prefix:   /link

BvaTouringBundle_backend:
   resource: "@BvaTouringBundle/Resources/config/routing/backend.yml"
   prefix:   /touring

As you can see the touring road is well there. Moreover...the link bundle just above is also one of those backend administration modules and there is no problem with that one.

(The backend.yml of Link and Touring are both empty).

To get more idea with the html twig line making the crash, for link bundle i have this: link/N where N can be any kind of number. The link for the frontend in fact.

But for some reason it's not working with touring...even if i have access to the frontend.

app/frontend.yml

BvaLinkBundle_frontend:
   resource: "@BvaLinkBundle/Resources/config/routing/frontend.yml"
   prefix:   /link

BvaTourringBundle_frontend:
   resource: "@BvaTouringBundle/Resources/config/routing/frontend.yml"
   prefix:   /touring

LinkBundle/frontend.yml

link:
   path:     /{instance}
   defaults: { _controller: BvaLinkBundle:Frontend/Frontend:index }

And

TouringBundle/frontend.yml

touring:
   pattern:  /itm_touring/{instance}
   defaults: { _controller: "BvaTouringBundle:Frontend/Frontend:index" }

So i would like to be able to see in the twig /touring/itm_touring/N whith N any number

1
Where app/backend/routing.yml was included? does path('link') in the twig templates working? - artemiuz
What is the value of instance.module.type? If you want to write a route to adm_module, then you have to use the route name as the parameter: path('adm_module', {…}). - A.L
The value of instance.module.type is touring. The twig is fine it works for all the modules. I just have this issue with the new one. But what I don't understand is that i have the touring road in frontend.yml of TouringBundle... - user8238012

1 Answers

0
votes

To add more details on the issue:

That was my twig

<a target="_blank" href="{{ path(instance.module.type, {'instance': instance.id}) }}"</a>

Working fine for all module except the one i just added and so i get an error 500 because instance.module.type ==> touring is not known.

So to remove the error I made something bad...but at least you can see the working path

This is working i just made a special case when i get touring...but i can't of course use it for prod...

{% if instance.module.type == "touring" %}
        <a target="_blank" href="./../../app_dev.php/touring/41"</a> 
{% else %}
         <a target="_blank" href="{{ path(instance.module.type, {'instance': instance.id}) }}"</a>
{% endif %}

I hope this is helpfull for the understanding.