mirror of
https://github.com/filegator/filegator.git
synced 2025-08-05 21:47:52 +02:00
initial commit
This commit is contained in:
34
backend/Controllers/ErrorController.php
Normal file
34
backend/Controllers/ErrorController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the FileGator package.
|
||||
*
|
||||
* (c) Milos Stojanovic <alcalbg@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE file
|
||||
*/
|
||||
|
||||
namespace Filegator\Controllers;
|
||||
|
||||
use Filegator\Kernel\Request;
|
||||
use Filegator\Kernel\Response;
|
||||
|
||||
class ErrorController
|
||||
{
|
||||
protected $request_type;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request_type = $request->getContentType();
|
||||
}
|
||||
|
||||
public function notFound(Response $response)
|
||||
{
|
||||
return $this->request_type == 'json' ? $response->json('Not Found', 404) : $response->html('Not Found', 404);
|
||||
}
|
||||
|
||||
public function methodNotAllowed(Response $response)
|
||||
{
|
||||
return $this->request_type == 'json' ? $response->json('Not Allowed', 401) : $response->html('Not Found', 401);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user