Hallo, it's not easy to write short code, because full version of Controller is very complex (DI), but I try:
abstract class Controller {
// Template method
public final function control(...) {
try {
$this->before();
$this->process();
return $this->after();
} catch ...
}
protected function before(...) {
// here is code to execute before processing of controller
// should throw many exceptions (rights etc.)
}
protected function process(...) {
// body of controller
}
protected function after(...) {
// typically return views data...
}
}
Method Controller::before() throws exceptions on a number of counts, but I am looking for clean way how to throw "silent exception", because controller should be called as "service" and in this case I do not need error message (you are not logged in...) but only stop processing and return context to other controller in queue.
Yes, it's easy to define some SilentException extends \Exception, but this I feel a little bit dirty.