I'm working on my project with yona-cms ([https://yonacms.com/]) and creating a new module. I add a route with a parameter and i try to check if the parameter value is valid. If it isn't valid then it'll be redirected to index page. I use this parameter as a variable in my view. So it will show error whenever i put wrong parameter value.
Here is my Routes.php code
public function init(DefaultRouter $router)
{
    $router->add('/editor/{theme:[a-zA-Z0-9_-]+}.html', [
        'module' => 'editor',
        'controller' => 'index',
        'action' => 'index'
    ]);
    return $router;
}and i check it in IndexController
public function initialize(){
    $template = Templates::findFirst(['template_slug' => $this->dispatcher->getParam("theme")]);
    if(!$template){
        $this->flash->notice('Wrong theme');
        $this->response->redirect($this->url->get() . 'index');
        return;
    }
}and the error i get is
Phalcon\Mvc\View\Exception: View 'F:\xampp\htdocs\kampret\app\modules\Editor/views/../../../views//partials/themes/theme-2' was not found in the views directory
How to stop it to not generating a view before the parameter value is valid? Hope you understand with my problem and sorry for my english.