Exemplo n.º 1
0
 /**
  * Kernel constructor.
  */
 public function __construct()
 {
     try {
         $this->Request = new Request();
         $this->Router = new Router($this->Request);
         $ControllerLoader = new ControllerLoader($this->Request->getController());
         if ($ControllerLoader->exist()) {
             $this->Controller = $ControllerLoader->getInstance($this->Request);
             if (method_exists($this->Controller, $this->Request->getAction())) {
                 call_user_func([$this->Controller, $this->Request->getAction()], $this->Request->getParams());
                 $Logger = new Logger('/logs/access.log');
                 $Date = new \DateTime('now');
                 $Logger->writeLine('[' . $Date->getTimestamp() . '] Path:' . $this->Request->getPath() . ' type:' . $this->Request->getMethod());
             } else {
                 $exception = new NotFoundException('Path:' . $this->Request->getPath() . ', Action ' . $this->Request->getAction() . ' not found in Controller ' . ucfirst($this->Request->getController() . 'Controller'));
                 throw $exception;
             }
         } else {
             $exception = new NotFoundException('Path:' . $this->Request->getPath() . ', Controller ' . ucfirst($this->Request->getController()) . 'Controller not found');
             throw $exception;
         }
     } catch (NotFoundException $e) {
         echo $e->cry();
     }
 }
 /**
  * Exception constructor.
  * @param string $message
  * @param int $code
  * @param \Exception|null $previous
  */
 public function __construct($message, $code = 0, \Exception $previous = null)
 {
     parent::__construct($message, $code, $previous);
     $Date = new \DateTime();
     $Logger = new Logger('/logs/error.log');
     $Logger->writeLine('[' . $Date->getTimestamp() . '] ' . $message);
 }