Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
Added Bootstrap component, removed Exception Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
o-alquimista committed Mar 21, 2020
1 parent b98bd80 commit 6813be6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 45 deletions.
64 changes: 64 additions & 0 deletions src/Fragments/Component/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* Copyright 2019-2020 Douglas Silva (0x9fd287d56ec107ac)
*
* This file is part of Fragments.
*
* Fragments is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fragments. If not, see <https://www.gnu.org/licenses/>.
*/

namespace Fragments\Component;

use Fragments\Component\Routing\Router;
use Fragments\Bundle\Exception\HttpException;
use Fragments\Component\TemplateHelper;

class Bootstrap
{
private $router;

private $templateHelper;

public function __construct()
{
$this->router = new Router;
$this->templateHelper = new TemplateHelper;
}

public function run()
{
try {
$this->router->start();
} catch (HttpException $error) {
$this->exceptionHandler($error);
}
}

private function exceptionHandler(HttpException $error)
{
$statusCode = $error->getStatusCode();
$message = $error->getMessage();

http_response_code($statusCode);
error_log($message);

$this->templateHelper->render('../templates/error/error_page.php', [
'statusCode' => $statusCode,
'message' => $message
]);

exit;
}
}
45 changes: 0 additions & 45 deletions src/Fragments/Component/ExceptionHandler.php

This file was deleted.

0 comments on commit 6813be6

Please sign in to comment.