1 | <?php |
||
2 | /** |
||
3 | * @package WPEmerge |
||
4 | * @author Atanas Angelov <[email protected]> |
||
5 | * @copyright 2018 Atanas Angelov |
||
6 | * @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0 |
||
7 | * @link https://wpemerge.com/ |
||
8 | */ |
||
9 | |||
10 | namespace WPEmerge\Exceptions; |
||
11 | |||
12 | use Whoops\Handler\PrettyPageHandler; |
||
13 | use Whoops\Run; |
||
14 | use WPEmerge\Facades\Application; |
||
15 | use WPEmerge\ServiceProviders\ExtendsConfigTrait; |
||
16 | use WPEmerge\ServiceProviders\ServiceProviderInterface; |
||
17 | |||
18 | /** |
||
19 | * Provide exceptions dependencies. |
||
20 | * |
||
21 | * @codeCoverageIgnore |
||
22 | */ |
||
23 | class ExceptionsServiceProvider implements ServiceProviderInterface { |
||
24 | use ExtendsConfigTrait; |
||
25 | |||
26 | /** |
||
27 | * {@inheritDoc} |
||
28 | */ |
||
29 | public function register( $container ) { |
||
30 | $this->extendConfig( $container, 'debug', [ |
||
31 | 'pretty_errors' => true, |
||
32 | ] ); |
||
33 | |||
34 | $container['whoops'] = function () { |
||
35 | if ( ! class_exists( Run::class ) ) { |
||
36 | return null; |
||
37 | } |
||
38 | |||
39 | $run = new Run(); |
||
40 | $run->allowQuit( false ); |
||
41 | $run->pushHandler( new PrettyPageHandler() ); |
||
42 | return $run; |
||
43 | }; |
||
44 | |||
45 | $container[ WPEMERGE_EXCEPTIONS_ERROR_HANDLER_KEY ] = function ( $c ) { |
||
46 | $whoops = $c[ WPEMERGE_CONFIG_KEY ]['debug']['pretty_errors'] ? $c['whoops'] : null; |
||
47 | return new ErrorHandler( $whoops, Application::debugging() ); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
48 | }; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritDoc} |
||
53 | */ |
||
54 | public function bootstrap( $container ) { |
||
55 | // Nothing to bootstrap. |
||
56 | } |
||
57 | } |
||
58 |