Bug #41252

Object Route Part to Integer ID generates dash in URL

Added by Mario Rimann almost 3 years ago. Updated about 2 years ago.

Status:Closed Start date:2012-09-22
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:MVC - Routing
Target version:-
PHP Version:5.3 Complexity:
Has patch:No Affected Flow version:FLOW3 1.1.0

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

History

#1 Updated by Bastian Waidelich about 2 years ago

  • Status changed from New to Needs Feedback
  • Assigned To 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:

 1-
 2  name: 'Task Detail view'
 3  uriPattern: 'tasks/{task}'
 4  defaults:
 5    '@package':    'My.Package'
 6    '@controller': 'Task'
 7    '@action':     'show'
 8  routeParts:
 9    'task':
10      objectType: 'My\Package\Domain\Model\Task'
11      uriPattern: '{id}'

#2 Updated by Mario Rimann about 2 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 2 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