I just type it in the address bar ![;)](http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif)
Here is my NavWidget config from layouts/main.php . Index works, Foo does not.
['label' => 'Videos', 'url' => ['/mbh/foxvid/index']],
['label' => 'Foo', 'url' => ['/mbh/foxvid/foo']],
If I have debugged correctly, the "method exists" call is failing.
DUMP output for a working call looks the same to me.
I am also getting a clue from the phpStorm IDE, but it is going over my head.
Notice the $id argument to Foo is greyed.
But the working actions (create, update,view),…) are not.
So phpStorm sees something …? http://…YIIMODULE.png
[b]
/vendor/yiisoft/yii2/base/Controller.php[/b] Here I dumped some vars to narrow it down to the method_exists call…
public function createAction($id)
{
if ($id === '') {
$id = $this->defaultAction;
}
$actionMap = $this->actions();
\stewlog::dump('ACTION MAP', $actionMap);
if (isset($actionMap[$id])) {
return Yii::createObject($actionMap[$id], [$id, $this]);
} elseif (preg_match('/^[a-z0-9\\-_]+$/', $id) && strpos($id, '--') === false && trim($id, '-') === $id) {
$methodName = 'action' . str_replace(' ', '', ucwords(implode(' ', explode('-', $id))));
\stewlog::dump('EXISTS?', get_class($this) . '::'. $methodName, (method_exists($this, $methodName) ?'YES':'NO' ));
if (method_exists($this, $methodName)) {
$method = new \ReflectionMethod($this, $methodName);
if ($method->isPublic() && $method->getName() === $methodName) {
return new InlineAction($id, $this, $methodName);
}
}
}
\stewlog::bm('nullret');
DUMP: Here the method_exists call fails
-------------------
2016-04-08 06:48:53
string(13) "runAction id="
string(3) "foo"
string(7) "params="
array(1) {
'r' =>
string(14) "mbh/foxvid/foo"
}
-------------------
2016-04-08 06:48:53
string(10) "ACTION MAP"
array(0) {
}
-------------------
2016-04-08 06:48:53
string(7) "EXISTS?"
string(55) "app\modules\mbh\controllers\FoxvidController::actionFoo"
string(2) "NO"
-------------------
2016-04-08 06:48:53
string(7) "nullret"
[b]
/modules/mbh/controllers/foxvid/FoxvidController.php[/b] Here I am namespaced and public, other calls wrk, why not Foo? Durn it.
namespace app\modules\mbh\controllers\foxvid;
...
class FoxvidController extends Controller
{
...
public function actionFoo($id)
{
die('foo');
}
}