Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix supporting of "artisan down" command #2519

Merged
merged 1 commit into from
May 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions app/Foundation/Exceptions/Displayers/MaintenanceDisplayer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Cachet\Foundation\Exceptions\Displayers;

use Exception;
use GrahamCampbell\Exceptions\Displayers\DisplayerInterface;
use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
use Illuminate\Http\Response;

/**
* This is the maintenance displayer class.
*
* @author James Brooks <james@alt-three.com>
*/
class MaintenanceDisplayer implements DisplayerInterface
{
/**
* The view factory instance.
*
* @var \Illuminate\Contracts\View\Factory
*/
protected $view;

/**
* Create a new maintenance displayer instance.
*
* @param \Illuminate\Contracts\View\Factory $view
*
* @return void
*/
public function __construct(Factory $view)
{
$this->view = $view;
}

/**
* Get the error response associated with the given exception.
*
* @param \Exception $exception
* @param string $id
* @param int $code
* @param string[] $headers
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function display(Exception $exception, $id, $code, array $headers)
{
return new Response($this->render(), $code, array_merge($headers, ['Content-Type' => $this->contentType()]));
}

/**
* Render the page.
*
* @return string
*/
protected function render()
{
return $this->view->make('errors.maintenance')->render();
}

/**
* Get the supported content type.
*
* @return string
*/
public function contentType()
{
return 'text/html';
}

/**
* Can we display the exception?
*
* @param \Exception $original
* @param \Exception $transformed
* @param int $code
*
* @return bool
*/
public function canDisplay(Exception $original, Exception $transformed, $code)
{
return $transformed instanceof MaintenanceModeException;
}

/**
* Do we provide verbose information about the exception?
*
* @return bool
*/
public function isVerbose()
{
return false;
}
}
2 changes: 1 addition & 1 deletion app/Foundation/Providers/ComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function boot(Factory $factory)
{
$factory->composer('*', AppComposer::class);
$factory->composer('*', CurrentUserComposer::class);
$factory->composer(['index', 'single-incident', 'subscribe.*', 'signup', 'dashboard.settings.theme', 'notifications::email', 'single-schedule'], ThemeComposer::class);
$factory->composer(['index', 'single-incident', 'subscribe.*', 'signup', 'dashboard.settings.theme', 'notifications::email', 'single-schedule', 'errors.*'], ThemeComposer::class);
$factory->composer('dashboard.*', DashboardComposer::class);
$factory->composer(['setup.*', 'dashboard.settings.localization'], TimezoneLocaleComposer::class);

Expand Down
1 change: 1 addition & 0 deletions config/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'CachetHQ\Cachet\Foundation\Exceptions\Displayers\JsonValidationDisplayer',
'CachetHQ\Cachet\Foundation\Exceptions\Displayers\RedirectDisplayer',
'CachetHQ\Cachet\Foundation\Exceptions\Displayers\ThrottleDisplayer',
'CachetHQ\Cachet\Foundation\Exceptions\Displayers\MaintenanceDisplayer',
'GrahamCampbell\Exceptions\Displayers\DebugDisplayer',
'GrahamCampbell\Exceptions\Displayers\HtmlDisplayer',
'GrahamCampbell\Exceptions\Displayers\JsonDisplayer',
Expand Down
12 changes: 12 additions & 0 deletions resources/views/errors/maintenance.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@extends('layout.master')

@section('content')
<div class="panel panel-info">
<div class="panel-heading">
<strong>Under Maintenance</strong>
</div>
<div class="panel-body">
<p>We're currently under maintnenance, come back shortly.</p>
</div>
</div>
@stop
4 changes: 4 additions & 0 deletions resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
@section('content')
@modules
@stop

@section('bottom-content')
@include('partials.footer')
@stop
2 changes: 1 addition & 1 deletion resources/views/layout/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@
@yield('content')
</div>

@include('partials.footer')
@yield('bottom-content')
</body>
</html>
4 changes: 4 additions & 0 deletions resources/views/signup.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@
</div>
</div>
@stop

@section('bottom-content')
@include('partials.footer')
@stop
4 changes: 4 additions & 0 deletions resources/views/single-incident.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@
</div>
@endif
@stop

@section('bottom-content')
@include('partials.footer')
@stop
4 changes: 4 additions & 0 deletions resources/views/single-schedule.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@
</div>
</div>
@stop

@section('bottom-content')
@include('partials.footer')
@stop