php - Doctrine2 - error when using @ParamConverter -


I try to retrieve the object with the translated slog, like:

1 - I Custom repository with one method:

  public function findByTranslatedSlug ($ slug, $ locale) {var_dump ($ _ locale); Exit; $ Qb = $ this- & gt; CreateQueryBuilder ('c') - & gt; Where ('c.slug =: slug') - & gt; Set parameter ($ slug); $ query = $ qb- & gt; GetQuery (); $ Query- & gt; SetHint (\ Doctrine \ ORM \ Query :: HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo \\ translucent \\ query \\ treewalker \\ translator' \ Gedmo \ Translatable \ TranslatableListener :: HINT_TRANSLATABLE_LOCALE, $ locale); Return $ query- & gt; GetOneOrNullResult (); } <-   

2 - My job is configured with @ParamConverter like this: (@ / {slug } "@ Template") @ParamConverter (* "content", * class = "StenikContentBundle: content", * option = {* "mapping" = {"_locale": "locale"} , * "Repository_moth" = "FindBytranslatedSlug" *} *) * / Public Function Index Action ($ content) {var_dump ($ content-> getSlug ()); Exit;

3 - Main routing

  stenik_content: resource: "@StankCentantBundle / Controller" type: Annotation prefix: / {_ locale}   

xxx.localhost / app_dev.php / en / some-slug , I'm getting a theory error :

Unable to guess to obtain a theory example with information from the request.

I can not find the reason for the error, maybe both the repository method and the mapping can not be used. Can you help

I can not directly examine the behavior, but I doubt that the problem is that you have Has specified which root placeholder matches the method parameter in your mapping entry, but not all required criteria are provided (and are also using custom repository method). Symphony can usually guess how to use placeholders to look at the unit, but not in unusual circumstances.

Edit: Just confirm in this - if mapping is set, then all mapping information (in an Associate array) is returned to $ repository- & Gt; Method named in search by method, or repository_method . This means that the method you choose will need to expect an Associate array as its parameter, not two separate Locale and slug parameters.

Then try this: / ** * @ Root ("/ {slug}", name = "name") * @ template () * @ ParamConverter (* "Content", * class = "StenikContentBundle: Content", * options = {* "mapping" = {"_locale": "locale", "slug": "slug"}, # include slug * repository_method "=" findBytranslated slug "*} *) * /

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -