firefly-iii/app/Http/Controllers/HelpController.php

56 lines
1.2 KiB
PHP
Raw Normal View History

2015-02-25 09:10:02 -06:00
<?php namespace FireflyIII\Http\Controllers;
2015-04-07 12:58:49 -05:00
use FireflyIII\Helpers\Help\HelpInterface;
2015-04-07 11:26:14 -05:00
use Log;
2015-02-25 09:10:02 -06:00
use Response;
2015-04-07 11:26:14 -05:00
2015-02-25 09:10:02 -06:00
/**
* Class HelpController
*
* @package FireflyIII\Http\Controllers
*/
2015-03-10 11:26:31 -05:00
class HelpController extends Controller
{
2016-01-08 11:29:47 -06:00
public function __construct()
{
$this->middleware('auth');
}
2015-02-25 09:10:02 -06:00
/**
2015-05-03 05:58:55 -05:00
* @param HelpInterface $help
* @param $route
2015-02-25 09:10:02 -06:00
*
* @return \Illuminate\Http\JsonResponse
*/
2015-05-03 05:54:39 -05:00
public function show(HelpInterface $help, $route)
2015-02-25 09:10:02 -06:00
{
$content = [
'text' => '<p>There is no help for this route!</p>',
'title' => 'Help',
];
2015-04-07 12:58:49 -05:00
if (!$help->hasRoute($route)) {
2015-04-07 11:25:21 -05:00
Log::error('No such route: ' . $route);
2015-02-25 09:10:02 -06:00
return Response::json($content);
}
2015-04-07 12:58:49 -05:00
if ($help->inCache($route)) {
2015-02-25 09:10:02 -06:00
$content = [
2015-04-07 12:58:49 -05:00
'text' => $help->getFromCache('help.' . $route . '.text'),
'title' => $help->getFromCache('help.' . $route . '.title'),
2015-02-25 09:10:02 -06:00
];
return Response::json($content);
}
2015-04-07 12:58:49 -05:00
$content = $help->getFromGithub($route);
2015-02-25 09:10:02 -06:00
2015-04-07 12:58:49 -05:00
$help->putInCache($route, $content);
2015-02-25 09:10:02 -06:00
return Response::json($content);
}
}