Skip to content

Commit f36994b

Browse files
committed
Allow to disable exception throwing in the View destructor
1 parent ed98bb8 commit f36994b

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

guide/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,7 @@ View Config Options
12661266
'layout_prefix' => null,
12671267
'include_prefix' => null,
12681268
'show_debug_comments' => true,
1269+
'throw_exceptions_in_destructor' => true,
12691270
],
12701271
],
12711272
]
@@ -1296,6 +1297,12 @@ show_debug_comments
12961297

12971298
Set to ``false`` to disable HTML comments when in debug mode.
12981299

1300+
throw_exceptions_in_destructor
1301+
""""""""""""""""""""""""""""""
1302+
1303+
Set ``false`` to not throw exceptions in the class destructor. The default is to
1304+
throw. Disabling this will help you debug exceptions thrown inside views.
1305+
12991306
Extending
13001307
#########
13011308

src/App.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,9 @@ protected static function setView(string $instance) : View
14321432
if (isset($config['show_debug_comments']) && $config['show_debug_comments'] === false) {
14331433
$service->disableDebugComments();
14341434
}
1435+
if (isset($config['throw_exceptions_in_destructor'])) {
1436+
$service->setThrowExceptionsInDestructor($config['throw_exceptions_in_destructor']);
1437+
}
14351438
return static::setService('view', $service, $instance);
14361439
}
14371440

tests/configs/view.config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
'layout_prefix' => '',
1515
'include_prefix' => '',
1616
'show_debug_comments' => false,
17+
'throw_exceptions_in_destructor' => false,
1718
],
1819
];

0 commit comments

Comments
 (0)