class ErrorHandlerSubscriber
Same name in other branches
- 4.x src/EventSubscriber/ErrorHandlerSubscriber.php \Drupal\devel\EventSubscriber\ErrorHandlerSubscriber
Listener for handling PHP errors.
Hierarchy
- class \Drupal\devel\EventSubscriber\ErrorHandlerSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ErrorHandlerSubscriber
1 string reference to 'ErrorHandlerSubscriber'
1 service uses ErrorHandlerSubscriber
File
-
src/
EventSubscriber/ ErrorHandlerSubscriber.php, line 13
Namespace
Drupal\devel\EventSubscriberView source
class ErrorHandlerSubscriber implements EventSubscriberInterface {
/**
* The current user.
*/
protected AccountProxyInterface $account;
/**
* ErrorHandlerSubscriber constructor.
*
* @param \Drupal\Core\Session\AccountProxyInterface $account
* The current user.
*/
public function __construct(AccountProxyInterface $account) {
$this->account = $account;
}
/**
* Register devel error handler.
*
* @param \Symfony\Component\HttpKernel\Event\RequestEvent|null $event
* The event to process.
*/
public function registerErrorHandler(?RequestEvent $event = NULL) : void {
if (!$this->account
->hasPermission('access devel information')) {
return;
}
devel_set_handler(devel_get_handlers());
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
// Runs as soon as possible in the request but after
// AuthenticationSubscriber (priority 300) because you need to access to
// the current user for determine whether register the devel error handler
// or not.
$events[KernelEvents::REQUEST][] = [
'registerErrorHandler',
256,
];
return $events;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ErrorHandlerSubscriber::$account | protected | property | The current user. |
ErrorHandlerSubscriber::getSubscribedEvents | public static | function | |
ErrorHandlerSubscriber::registerErrorHandler | public | function | Register devel error handler. |
ErrorHandlerSubscriber::__construct | public | function | ErrorHandlerSubscriber constructor. |