Skip to content

Commit d7cd3ca

Browse files
committed
Merge branch 'master' into navigation
2 parents 4b1bd7f + 7c1613e commit d7cd3ca

32 files changed

+288
-405
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"gulp": "^3.8.8"
55
},
66
"dependencies": {
7-
"laravel-elixir": "^4.0.0",
8-
"bootstrap-sass": "^3.0.0",
7+
"gulp": "^3.9.1",
8+
"laravel-elixir": "^5.0.0",
9+
"bootstrap-sass": "^3.3.0",
910
"bower-installer": "^1.2.0"
1011
}
1112
}

src/Contracts/ControllerACLInterface.php

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace KodiCMS\CMS\Contracts\Listeners;
4+
5+
interface BackendSettingsSave
6+
{
7+
/**
8+
* @param \KodiCMS\CMS\Events\BackendSettingsSave $event
9+
*/
10+
public function handle(\KodiCMS\CMS\Events\BackendSettingsSave $event);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace KodiCMS\CMS\Contracts\Listeners;
4+
5+
interface BackendSettingsValidate
6+
{
7+
/**
8+
* @param \KodiCMS\CMS\Events\BackendSettingsValidate $event
9+
*/
10+
public function handle(\KodiCMS\CMS\Events\BackendSettingsValidate $event);
11+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace KodiCMS\CMS\Contracts;
4+
5+
use ArrayAccess;
6+
7+
interface SettingsInterface extends ArrayAccess
8+
{
9+
/**
10+
* @return array
11+
*/
12+
public function booleanSettings();
13+
14+
/**
15+
* @return array
16+
*/
17+
public function defaultSettings();
18+
19+
/**
20+
* @return array
21+
*/
22+
public function getSettings();
23+
24+
/**
25+
* @param string $name
26+
* @param mixed $default
27+
*
28+
* @return mixed
29+
*/
30+
public function getSetting($name, $default = null);
31+
32+
/**
33+
* @param string $name
34+
* @param mixed $value
35+
*
36+
* @return $this
37+
*/
38+
public function setSetting($name, $value = null);
39+
40+
/**
41+
* @param array $settings
42+
*
43+
* @return $this
44+
*/
45+
public function setSettings(array $settings);
46+
47+
/**
48+
* @param array $settings
49+
*
50+
* @return $this
51+
*/
52+
public function replaceSettings(array $settings);
53+
}

src/Events/BackendSettingsSave.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace KodiCMS\CMS\Events;
4+
5+
class BackendSettingsSave
6+
{
7+
/**
8+
* @var array
9+
*/
10+
private $settings;
11+
12+
/**
13+
* BackendSettingsHandler constructor.
14+
*
15+
* @param array $settings
16+
*/
17+
public function __construct(array $settings)
18+
{
19+
$this->settings = $settings;
20+
}
21+
22+
/**
23+
* @return array
24+
*/
25+
public function settings()
26+
{
27+
return $this->settings;
28+
}
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace KodiCMS\CMS\Events;
4+
5+
use Illuminate\Validation\Validator;
6+
7+
class BackendSettingsValidate
8+
{
9+
/**
10+
* @var Validator
11+
*/
12+
private $validator;
13+
14+
/**
15+
* BackendSettingsHandler constructor.
16+
*
17+
* @param Validator $validator
18+
*/
19+
public function __construct(Validator $validator)
20+
{
21+
$this->validator = $validator;
22+
}
23+
24+
/**
25+
* @return Validator
26+
*/
27+
public function validator()
28+
{
29+
return $this->validator;
30+
}
31+
}

src/Exceptions/Handler.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace KodiCMS\CMS\Exceptions;
44

5+
use Exception;
56
use Illuminate\Http\Response;
67
use KodiCMS\API\Http\Response as APIResponse;
8+
use KodiCMS\CMS\Exceptions\ValidationException;
79
use KodiCMS\CMS\Http\Controllers\ErrorController;
810
use Illuminate\Auth\Access\AuthorizationException;
911
use KodiCMS\API\Exceptions\Exception as APIException;
@@ -20,6 +22,7 @@ class Handler extends ExceptionHandler
2022
* @var array
2123
*/
2224
protected $dontReport = [
25+
HttpException::class,
2326
AuthorizationException::class,
2427
HttpException::class,
2528
ModelNotFoundException::class,
@@ -35,7 +38,7 @@ class Handler extends ExceptionHandler
3538
*
3639
* @return void
3740
*/
38-
public function report(\Exception $e)
41+
public function report(Exception $e)
3942
{
4043
return parent::report($e);
4144
}
@@ -44,11 +47,11 @@ public function report(\Exception $e)
4447
* Render an exception into an HTTP response.
4548
*
4649
* @param \Illuminate\Http\Request $request
47-
* @param \Exception $e
50+
* @param Exception $e
4851
*
4952
* @return \Illuminate\Http\Response
5053
*/
51-
public function render($request, \Exception $e)
54+
public function render($request, Exception $e)
5255
{
5356
if ($request->ajax() or ($e instanceof APIException)) {
5457
return $this->renderApiException($e);
@@ -58,7 +61,7 @@ public function render($request, \Exception $e)
5861
$e = new NotFoundHttpException($e->getMessage(), $e);
5962
}
6063

61-
if (config('app.debug') or ! cms_installed()) {
64+
if ((config('app.debug')and ! app()->runningInConsole()) or ! cms_installed()) {
6265
return $this->renderExceptionWithWhoops($e);
6366
} elseif (! $this->isHttpException($e)) {
6467
return $this->renderException($e);
@@ -94,20 +97,20 @@ protected function renderHttpException(HttpException $e)
9497
*
9598
* @return \Illuminate\Http\Response
9699
*/
97-
protected function renderException(\Exception $e)
100+
protected function renderException(Exception $e)
98101
{
99102
return $this->renderControllerException($e, 500);
100103
}
101104

102105
/**
103106
* Render an exception using ErrorController.
104107
*
105-
* @param \Exception $e
108+
* @param Exception $e
106109
* @param int $code
107110
*
108111
* @return \Illuminate\Http\Response
109112
*/
110-
protected function renderControllerException(\Exception $e, $code = 500)
113+
protected function renderControllerException(Exception $e, $code = 500)
111114
{
112115
try {
113116
$controller = app()->make(ErrorController::class);
@@ -125,8 +128,8 @@ protected function renderControllerException(\Exception $e, $code = 500)
125128
}
126129

127130
return $this->toIlluminateResponse($response);
128-
} catch (\Exception $ex) {
129-
return $this->convertExceptionToResponse($ex);
131+
} catch (Exception $ex) {
132+
return $this->toIlluminateResponse($this->convertExceptionToResponse($ex), $ex);
130133
}
131134
}
132135

@@ -137,15 +140,11 @@ protected function renderControllerException(\Exception $e, $code = 500)
137140
*
138141
* @return \Illuminate\Http\Response
139142
*/
140-
protected function renderExceptionWithWhoops(\Exception $e)
143+
protected function renderExceptionWithWhoops(Exception $e)
141144
{
142145
$whoops = new \Whoops\Run;
143-
$whoops->pushHandler(
144-
new \Whoops\Handler\PrettyPageHandler
145-
);
146+
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
146147

147-
return $this->toIlluminateResponse(
148-
new Response($whoops->handleException($e)), $e
149-
);
148+
return $this->toIlluminateResponse($whoops->handleException($e), $e);
150149
}
151150
}

src/Handlers/Events/SettingsSave.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Handlers/Events/SettingsValidate.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)