Sign up ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have an entity and when I try to pass the whole entity object, only the name is passed through the routing.

Here is the relevant code in routing.yml:

  path: '/admin/config/mymodule/myentity/{myentity}/info'
    _content: '\Drupal\mymodule\Controller\MyModuleController::info'
    _title: 'Myentity Info'
      type: entity:myentity
    _entity_create_access: 'mymodule_myentity'

After clicking the link, I get this error: Trying to get property of non-object

I've added an issue regarding this to my sandbox project:

share|improve this question
Couldn't be as simple as type not being indented correctly under the parameters? – Clive Jul 10 '14 at 0:46
@Clive: Nope. It still throws he same error. I tried doing a print_r($myentity). It just displays the name of that entity I added in string. Is there any example which I could refer to maybe? – xan Jul 10 '14 at 0:51
@Clive` I'm disturbed that the YAML options: and parameters: keys doesn't appear anywhere in google search results, or like or a change record i can find :( – tenken Jul 10 '14 at 0:59
@Clive: Yes. I took that from Basically, I'm trying to output an entity's info. The info($myentity) function should take the argument as the Entity object, but all it does is take just the name. – xan Jul 10 '14 at 1:02
Maybe you need a custom parameter converter for your entity type? I can't look right now but search around the change records and the new routing docs for parameter upcasting. I'm not sure if you're automagically provided one – Clive Jul 10 '14 at 1:05

1 Answer 1

up vote 6 down vote accepted

What you are looking for is now called upcasting, the handbook page is

I do not think options is necessarily for entity upcasting. For example, check the node.type_edit in core/modules/node/node.routing.yml for a routing definition not using any options (or user.admin_permission in user).

As with your previous question, I wonder whether your entity class properly defines its storage controller? If you have a debugger, the parameter conversion happens in core/lib/Drupal/Core/ParamConverter/EntityConverter.php

share|improve this answer
I followed your advice, and still was unable to debug it. You could view the issue that I've added to my sandbox project. – xan Jul 11 '14 at 23:21
Seems like the function name info was posing problems, maybe having conflicts. Changing the function name resolved the issue. Thanks! – xan Jul 13 '14 at 15:45
Which function name have you changed...? This sounds curious. – chx Jul 13 '14 at 16:32
You may view my commit:… – xan Jul 13 '14 at 16:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.