I have a ActiveController. The default action work for crud but i have an extraPatterns and define it in my actions():
$actions['all'] = [
'class' => All::class,
'modelClass' => $this->modelClass,
'checkAccess' => [$this, 'checkAccess'],
];
This error just occurred in all route not default crud actions.
Create url in my model with Url::to(['test/view', 'id' => 12], true)
Url should be created, I implement getLinks method in my model.
This Error:
"message": "Unable to resolve the relative route: test/view. No active controller is available.",
| Q | A |
| --- | --- |
| Yii version | dev-master |
| PHP version | 5.6 |
| Operating system | Ubuntu 14.04 |
Url::to(['test/view', 'id' => 12], true)
use '/test/view' insetad of 'test/view'.
_This is an automated comment, triggered by adding the label question._
Please note, that the GitHub Issue Tracker is for bug reports and feature requests only.
We are happy to help you on the support forum, on IRC (#yii on freenode), or Gitter.
Please use one of the above mentioned resources to discuss the problem.
If the result of the discussion turns out that there really is a bug in the framework, feel free to
come back and provide information on how to reproduce the issue. This issue will be closed for now.
@cebe Thank you. But this is not correctly create the url, Your solution created url is:
http://localhost/api/web/test/view?id=57da7cf054df560d2e10d191
But expected is this:
http://localhost/api/web/v1/test/57da7cf054df560d2e10d191
I used module for my rest services.
When i use default rest action the url correctly create like an index or view action.
@jafaripur
show your url rules and extraPaterns
[
'class' => \yii\rest\UrlRule::class,
'controller' => 'v1/test',
'pluralize' => false,
'tokens' => [
'{id}' => '<id:\\w+>'
],
'extraPatterns' => [
'GET all' => 'all',
'OPTIONS all' => 'options',
],
],
The problem is just exist in all route.
This error just occurred in
allroute not default crud actions.
The problem is just exist inallroute.
IMO this issue is come from your All class not from yii
All route class is a normal action and extend from yii\rest\Action and similar to rest default view route yii\rest\ViewAction
@jafaripur could you check whether this issue has been fixed in YIi 2.0.10?
related to #12795
@cebe Yes, It's fixed.
Great, thanks for the feedback!