2014-11-23 21:34:31 +00:00
|
|
|
<?php
|
|
|
|
|
2015-04-19 08:52:39 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Cachet.
|
|
|
|
*
|
2015-07-06 17:37:01 +01:00
|
|
|
* (c) Alt Three Services Limited
|
2015-04-19 08:52:39 +01:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2015-03-20 18:30:45 -06:00
|
|
|
namespace CachetHQ\Cachet\Http\Middleware;
|
2015-01-02 00:18:19 +00:00
|
|
|
|
2017-01-03 14:30:39 +00:00
|
|
|
use CachetHQ\Cachet\Settings\Repository;
|
2015-03-20 18:30:45 -06:00
|
|
|
use Closure;
|
2016-02-11 11:35:40 +00:00
|
|
|
use Illuminate\Http\Request;
|
2015-01-02 00:18:19 +00:00
|
|
|
|
2016-10-08 10:37:21 +01:00
|
|
|
/**
|
|
|
|
* This is the ready for use middleware class.
|
|
|
|
*
|
|
|
|
* @author Graham Campbell <james@alt-three.com>
|
|
|
|
* @author James Brooks <james@alt-three.com>
|
|
|
|
* @author Joseph Cohen <joe@alt-three.com>
|
|
|
|
*/
|
2015-12-24 17:30:59 +00:00
|
|
|
class ReadyForUse
|
2014-12-20 21:20:17 +00:00
|
|
|
{
|
2016-12-03 19:25:39 +00:00
|
|
|
/**
|
2017-01-03 14:30:39 +00:00
|
|
|
* The settings repository instance.
|
2016-12-03 19:25:39 +00:00
|
|
|
*
|
2017-01-03 14:30:39 +00:00
|
|
|
* @var \CachetHQ\Cachet\Settings\Repository
|
2016-12-03 19:25:39 +00:00
|
|
|
*/
|
2017-01-03 14:30:39 +00:00
|
|
|
protected $settings;
|
2016-12-03 19:25:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new setup already completed middleware instance.
|
|
|
|
*
|
2017-01-03 14:30:39 +00:00
|
|
|
* @param \CachetHQ\Cachet\Settings\Repository $settings
|
2016-12-03 19:25:39 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2017-01-03 14:30:39 +00:00
|
|
|
public function __construct(Repository $settings)
|
2016-12-03 19:25:39 +00:00
|
|
|
{
|
2017-01-03 14:30:39 +00:00
|
|
|
$this->settings = $settings;
|
2016-12-03 19:25:39 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 00:54:16 +00:00
|
|
|
/**
|
2015-12-24 17:30:59 +00:00
|
|
|
* Handle an incoming request.
|
2015-01-02 00:54:16 +00:00
|
|
|
*
|
2015-12-22 08:41:03 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
2015-01-02 00:54:16 +00:00
|
|
|
*
|
2015-03-20 18:30:45 -06:00
|
|
|
* @return mixed
|
2015-01-02 00:54:16 +00:00
|
|
|
*/
|
2016-02-11 11:35:40 +00:00
|
|
|
public function handle(Request $request, Closure $next)
|
2014-12-20 21:20:17 +00:00
|
|
|
{
|
2017-01-03 14:30:39 +00:00
|
|
|
if (!$this->settings->get('app_name')) {
|
2016-12-03 19:25:39 +00:00
|
|
|
return cachet_redirect('setup');
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
2015-03-20 18:30:45 -06:00
|
|
|
|
|
|
|
return $next($request);
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|