Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions framework/yii/base/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ public function createAction($id)
}
}
}
return $this->missingAction($id);
}

/**
* This method is invoked when the requested action could not be found.
* You may override this method to create an action instance on demand.
* @param string $id the id of the requested action.
* @return Action the newly created action instance. Null if the ID doesn't resolve into any action.
* @see createController
*/
public function missingAction($id)
{
return null;
}

Expand Down
18 changes: 16 additions & 2 deletions framework/yii/base/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ public function createController($route)
$className = str_replace(' ', '', ucwords(implode(' ', explode('-', $id)))) . 'Controller';
$classFile = $this->controllerPath . DIRECTORY_SEPARATOR . $className . '.php';
if (!is_file($classFile)) {
return false;
return $this->missingController($id, $route);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 621 should also be modified similarly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is line 621 :)

}
$className = ltrim($this->controllerNamespace . '\\' . $className, '\\');
Yii::$classMap[$className] = $classFile;
Expand All @@ -629,7 +629,21 @@ public function createController($route)
}
}

return isset($controller) ? array($controller, $route) : false;
return isset($controller) ? array($controller, $route) : $this->missingController($id, $route);
}

/**
* This method is invoked when the requested controller could not be found.
* You may override this method to create a controller instance on demand.
* @param string $id the id of the requested controller.
* @param string $action the id of the requested action.
* @return array|boolean If the controller is created successfully, it will be returned together
* with the requested action ID. Otherwise false will be returned.
* @see createController
*/
public function missingController($id, $action)
{
return false;
}

/**
Expand Down