Bug #41252

Object Route Part to Integer ID generates dash in URL

Added by Mario Rimann about 9 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Should have
Category:
MVC - Routing
Target version:
-
Start date:
2012-09-22
Due date:
% Done:

0%

Estimated time:
PHP Version:
5.3
Has patch:
No
Complexity:

Description

I have a model that has an ID property that is configured like:

    /**
     * The ID of this task
     *
     * @var integer
     * @FLOW3\Identity
     * @ORM\Column(columnDefinition="INT(11) NOT NULL AUTO_INCREMENT UNIQUE")
     */
    protected $id;

And the following route definition:

-
  name: 'Task Detail view'
  uriPattern: 'tasks/{task}'
  defaults:
    '@package':    'My.Package'
    '@controller': 'Task'
    '@action':     'show'
  routeParts:
    task:
      objectType: 'My\Package\Domain\Model\Task'

Using the following Fluid Snippet, my list view generates URLs that are working properly - but showing a "-" in the URL that I don't expect/want to be in the URL:

<f:link.action action="show" controller="Task" arguments="{task: task}">
    {task.title}
</f:link.action>

Expected URL:

http://dev.foo.lo/tasks/15

Current URL:

http://dev.foo.lo/tasks/-15

#1

Updated by Bastian Waidelich about 8 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Bastian Waidelich

Hi Mario,

just stumbled upon this one now..
Is this issue still relevant to you?

The IdentityRoutePart handler that is used for object routes usually only inserts a dash to avoid duplicates:
If you have two objects with the identifier "test" the handler would create a route part "test" for the first and "test-1" for the second one.
So I suspect that in your case something went wrong with the identifier and the route part handler appended an increasing number to an empty string.

If this still occurs, please try to explicitly set the property to be used for the route part like so:

-
  name: 'Task Detail view'
  uriPattern: 'tasks/{task}'
  defaults:
    '@package':    'My.Package'
    '@controller': 'Task'
    '@action':     'show'
  routeParts:
    'task':
      objectType: 'My\Package\Domain\Model\Task'
      uriPattern: '{id}'

#2

Updated by Mario Rimann about 8 years ago

Bastian Waidelich wrote:

just stumbled upon this one now..
Is this issue still relevant to you?

I think it isn't - can't even remember which project this was :-) I'm fine with closing this one here for the moment.

#3

Updated by Bastian Waidelich about 8 years ago

  • Status changed from Needs Feedback to Closed

Closing the issue for now.
Thanks Mario and sorry for the slow feedback.

Also available in: Atom PDF