Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

yii\rest\UrlRule doesn't support route params. #7

Closed
yii-bot opened this issue Apr 5, 2018 · 1 comment
Closed

yii\rest\UrlRule doesn't support route params. #7

yii-bot opened this issue Apr 5, 2018 · 1 comment

Comments

@yii-bot
Copy link

yii-bot commented Apr 5, 2018

This issue has originally been reported by @Faryshta at yiisoft/yii2#13968.
Moved here by @samdark.


What steps will reproduce the problem?

on config/main.php

'urlManager' => [
    'rules' => [
        [
            'class' => \yii\rest\UrlRule::class,
            'controller' => ['store/<store_id:\d+>/employee' => 'store-employee'],
        ],
    ],
],

What is the expected result?

use the StoreEmployeeController controller when accessing the route store/1/employee

What do you get instead?

http status 404 the rest rule is not even parsed.

Additional info

caused by line https://github.com/yiisoft/yii2/blob/master/framework/rest/UrlRule.php#L221 since it executes

strpos('store/1/employee', 'store/<store_id:\d+>/employee')

which obviously will return false. there is no work-around this. when removing this line (and the ending bracket) the url is parsed properly.

@samdark
Copy link
Member

samdark commented Sep 8, 2020

Current router supports that.

@samdark samdark closed this as completed Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants