When setting up SonataAdmin, you have to add an entry like this one:
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
In this entry, what does resource: . do? It's somewhat unusual syntax and I'd like to add a footnote about it to the SonataAdmin docs.
The routing component needs a resource attribute (at least with sf2.0). The AdminPoolLoader class is in charge on loading the route and the support method only check the type attribute and not the resource name provided ....
So the dot is just a value that others RoutingLoader cannot validate and generate errors...
Related
I am using symfony5 and what I want to achive is to use a parameter in another parameter. Is it possible? Of course I've searchd for it, but did not find a solution. For example:
media:
extendions:
- pdf
path: '%kernel.project_dir%/media/'
incomingPdf:
#path: '%kernel.project_dir%/media/incoming/pdf'
path: '#=parameter("media")["path"]incoming/pdf'
It says, expressions is not allowed in parameters.
In incomingPdf I want to use defined media['path']s value.
I need do something like this:
users1:
resource: '#MyOwnBundle/Resources/config/routing/users.yaml'
prefix: '/users1'
users2:
resource: '#MyOwnBundle/Resources/config/routing/users.yaml'
prefix: '/users2'
I need defined the same resource for two diferent prefix, but it doen't works, what is a good way to do this?
I would like to overwrite default routing of FOSUserBundle for Symfony2 to get a result like this:
www.mysite.com/en/login
www.mysite.com/es/login
www.mysite.com/fr/login
www.mysite.com/en/profile
www.mysite.com/es/profile
www.mysite.com/fr/profile
Thanks for your help.
Look at this link. I think it is exactly what you need.
[...] to add a prefix before the _locale string (e.g. /admin/en/dashboard), you can add the “i18n_prefix” option.
# app/config/routing.yml
dashboard:
...
options: { i18n_prefix: admin }
I'm trying to build my own CMS based on Symfony 2 since I swapped jobs and now require some symfony practice, but got stuck when trying to do something sensible with routes. In Zend it was possible with preDispatch so I hope Symfony 2 will have something similar too.
Consider this URL: http://www.example.com/page_one/sub_page/another_sub_page/yet_another_sub/
What I am trying to achieve is to have http://www.example.com/page_one/ matching to some controller and getting me the content of the page that has the url_string parameter same as that portion of URL. Then http://www.example.com/page_one/sub_page/ should also match to the same controller but render content for the sub_page portion of URL.
The route must match n portions because I cannot know how deep the structure might go.
So I will not accept something like
/{slug1} or
/{slug1}/{slug2} or
/{slug1}/{slug2}/{slug3}
as that is nonsense.
I am planning to make this route as last one in the routing config so should there be some matches on other routes they will be picked up instead, and this one despite it is most important route will be last resort matching kinda thing.
Using the following config will match all urls, and the entire path will be passed into the controller "slug1/slug2/slug3".
SymfonyBundle/DefaultBundle/Resources/config/routing.yml:
symfony_default_page:
path: /{path}
defaults: { _controller: SymfonyBundle:Default:page }
requirements:
path: "^.+"
Or** ou can also use regex in the requirements path. This will exclude "admin", "login", "blog", however it's much easier if you simplify things and just place the routing in the correct order like you said
requirements:
path: "^(?!admin|login|blog).+"
app/config/routing.yml
By importing the default bundle routing last, it means any routing yml files above will take priority and therefore not match the default route which will catch any url.
SymfonyAdminBundle:
resource: "#SymfonyAdminBundle/Resources/config/routing.yml"
prefix: /admin
#import this last
SymfonyDefaultBundle:
resource: "#SymfonyDefaultBundle/Resources/config/routing.yml"
prefix: /
Controller:
class DefaultController extends Controller
{
public function pageAction($path)
{
//You could split the URL and handle accordingly, also filter / escape?
$parts = explode("/", $path);
}
}
Hello i have a strange problem, while using FostRestBundle.
First error is :
InvalidArgumentException: Every parent controller must have get{SINGULAR}Action($id) method
where {SINGULAR} is a singular form of associated object
And the second one :
Cannot import resource "/home/a15net/public_html/game/src/ATL/ContentBundle/Resources/config/api_routing.yml" from "/home/a15net/public_html/game/app/config/routing.yml".
I'v checked my all "YAML" files but there was no indent problems.
Tried to update composer twice nothing helped.
Edit : Config.yml > http://goo.gl/dqCAu
You have to remove the 'type' from this import statement fro your routing.yml
atl_content_api:
resource: "#ATLContentBundle/Resources/config/api_routing.yml"
Inside the api_routing.yml you can specify the rest type for each controller like,
acme_user_rest:
resource: Acme\UserBundle\Controller\UserRestController
prefix: /api
type: rest
this blog will help you to implement the sme
--- NOT --- SOLUTION :
If a route has a parent route, you must not put "type:rest" to it. You have to use "type:rest" only in parent routes.
Sample :
catalogs:
type: rest
prefix: api
resource: ATL\CatalogBundle\Controller\API\CatalogsController
options:
expose: true
taxonomy:
parent: catalogs
resource: ATL\CatalogBundle\Controller\API\TaxonomyController
options:
expose: true
I will not choose this as correct answer until more comments and other solution suggestions writed.
Edit
When you remove type:rest from children route, it is not a rest route anymore.