How to generate URL for another admin class

5,953 views
Skip to first unread message

Joe Turner

unread,
Apr 2, 2012, 8:23:27 AM4/2/12
to sonata-users
Hi,
How do I generate a URL for a page in a class different from the
controller that I am in?

i.e.

generateUrl('create') is good for generating create url for current
one....

But how about if I i wanted 'create' within another admin class?

Been googling and reading through notes and just can't seem to figure
it out!

Thanks

Joe

Herbert Fischer

unread,
Jun 14, 2012, 7:33:10 PM6/14/12
to sonata...@googlegroups.com, joean...@gmail.com
Did you found out how to do it? I also would like to know.


Joe

--
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To post to this group, send email to sonata...@googlegroups.com.
To unsubscribe from this group, send email to sonata-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sonata-users?hl=en.


Thomas Rabaix

unread,
Jun 15, 2012, 3:53:30 AM6/15/12
to sonata...@googlegroups.com, joean...@gmail.com
you can dump all routes available with app/console route:dump
--
Thomas Rabaix
http://rabaix.net | http://sonata-project.org

Herbert Fischer

unread,
Jun 18, 2012, 12:32:35 PM6/18/12
to sonata...@googlegroups.com, joean...@gmail.com
thanks... I've used the symfony's tradicional twig function

winso

unread,
Nov 28, 2012, 10:21:33 AM11/28/12
to sonata...@googlegroups.com, joean...@gmail.com
what is the solution for that ?

Jakala

unread,
Nov 28, 2012, 2:25:49 PM11/28/12
to sonata...@googlegroups.com
hello Winso:

the solution that i use is to add this different class with addchild method in your admin service. With this, you can call method generateUrl() like this:

$this->getChild('injectedclass').generateUrl('list');

in your service:

...
...  calls:
        [ addchild, ['@admin.injectedclass'] ]


Message has been deleted

jonben

unread,
Nov 29, 2012, 4:57:32 AM11/29/12
to sonata...@googlegroups.com, joean...@gmail.com
Dumping all the routes gives them in such format "admin_application_main_unit_create", you can then use path in twig.

{% if object.id %}
<a href="{{ path('admin_application_main_unit_create', {'owner_id': object.id}) }}" class="view_link" title="">[Create an Unit]</a>
{% else %}

Here there will be ?owner_id=(value) added to the url.
Reply all
Reply to author
Forward
0 new messages