my question is simple, how do I redefine the constructor of the parent class, with different behavior?
What I want to do is inherit from the Exceptional class of php (that its constructor prints the exception on screen), and redefine that constructor so that it does not show anything.
<?php
class Excepcion404 extends Exception{
public function __construct() {
//Este metodo muestra una vista
Vista::crear(GENERAL_BUNDLE."views/index.php");
}
}
When I do:
throw new Excepcion404();
The result I get is that it shows me the view, but below all this:
Fatal error: Uncaught Excepcion404 in C:\xampp\htdocs\Neomix\controladorFrontal\ruta.php:64
Stack trace:
#0 C:\xampp\htdocs\Neomix\controladorFrontal\ruta.php(18): Ruta->buscarEnElArray('/dafasdwdaw')
#1 C:\xampp\htdocs\Neomix\controladorFrontal\ruta.php(8): Ruta->submit()
#2 C:\xampp\htdocs\Neomix\rutas\rutas.php(7): Ruta->controladores(Array)
#3 C:\xampp\htdocs\Neomix\controladorFrontal\core.php(29): include('C:\xampp\htdocs...')
#4 C:\xampp\htdocs\Neomix\index.php(6): include('C:\xampp\htdocs...')
#5 {main} thrown in C:\xampp\htdocs\Neomix\controladorFrontal\ruta.php on line 64
I would like you to just show me the view and not to print that horrible mistake.
ADDED:
I'm building my own framework, when I capture the URI what I do is call a function that looks in an array, if that URI exists in my web, in case of finding it, it returns the driver that I will use and the method :
...código...
$respuesta = ruta.buscarEnElArray($urlCapturada);
...código...
and my role does the following:
public function buscarEnElArray($rutaABuscar){
foreach ($this->_controladores as $url => $controladorYmetodo) {
if($url == $rutaABuscar){
return $controladorYmetodo;
}
}
throw new Excepcion404();
}
Of course, thank you very much!