How To Implement Missing Controller

Hi,

As we have seen in controller that there is one function missingAction($actionID) in CController. By using this function I can simply tell my application that what it should do when one action is missing in a controller.

Is there any such function by over ridding which I can simply implement the same thing for controller. i.e missingController kinda thing.

Also is there any such function or any configuration available for Module, so that if one module is not found it can be handled?

Thanks,

Maclein

You could extend CWebApplication and invoke you own implementation instead, this code seems to deal with the controller invocation:





	/**

	 * Creates the controller and performs the specified action.

	 * @param string $route the route of the current request. See {@link createController} for more details.

	 * @throws CHttpException if the controller could not be created.

	 */

	public function runController($route)

	{

		if(($ca=$this->createController($route))!==null)

		{

			list($controller,$actionID)=$ca;

			$oldController=$this->_controller;

			$this->_controller=$controller;

			$controller->init();

			$controller->run($actionID);

			$this->_controller=$oldController;

		}

		else

			throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".',

				array('{route}'=>$route===''?$this->defaultController:$route)));

	}



You could override this and either replace it or call the parent and catch the exception and recall the logic to instantiate and invoke your missing controller. Your other option is to override createController and do the work in there. For missing modules see CWebApplication::findModule()

Thanks Luke,

That definitely ll help me.