Is there any possibility to handle message (in event or by exception) about view file non-existence?
|  | Dec '13 | 4 | 1974 | 2 | 
Is there any possibility to handle message (in event or by exception) about view file non-existence?
You can do that with a try/catch and handle the exception as it comes in
        try {
            $application = new \Phalcon\Mvc\Application();
            $application->setDI($di);
            return $application->handle()->getContent();
        } catch (\Phalcon\Exception $e) {
            echo $e->getMessage();
        } catch (\PDOException $e) {
            echo $e->getMessage();
        }You can attach a plugin that throws an exception when the view is not found, something like this:
$di['view'] = function() {
    //Create an event manager
    $eventsManager = new Phalcon\Events\Manager();
    //Attach a listener for type "view"
    $currentPath = null;    
    $eventsManager->attach("view", function($event, $view) use (&$currentPath) {
        if ($event->getType() == 'beforeRenderView') {
            if (!$currentPath) {
                $currentPath = $view->getActiveRenderPath();
            } else {
                throw new Exception('View not found' . $view->getActiveRenderPath());
            }
        } else {
            if ($view->getActiveRenderPath() == $currentPath) {
                $currentPath = null;
            }
        }
    });
    $view = new \Phalcon\Mvc\View();
    $view->setViewsDir("../app/views/");
    //Bind the eventsManager to the view component
    $view->setEventsManager($eventManagers);
    return $view;
};Thanks, but there is no exception. And i tries event manager... $view->getActiveRenderPath() is always '' (empty) Maybe i forgot something to implement in https://github.com/lantian/PhalconEye/blob/master/app/library/Engine/Application.php#L174 ?
I added a new event 'notFoundView' to handle this situation better:
$di['view'] = function() {
  //Create an event manager
  $eventsManager = new Phalcon\Events\Manager();
  //Attach a listener for type "view"
  $eventsManager->attach("view", function($event, $view) {
    if ($event->getType() == 'notFoundView') {      
        throw new Exception('View not found' . $view->getActiveRenderPath());
      }
    } 
  });
  $view = new \Phalcon\Mvc\View();
  $view->setViewsDir("../app/views/");
  //Bind the eventsManager to the view component
  $view->setEventsManager($eventManagers);
  return $view;
};This is available in the 1.0.0 branch