SystemFacade.php 960 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @package Grav\Common\Errors
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Errors;
  9. class SystemFacade extends \Whoops\Util\SystemFacade
  10. {
  11. protected $whoopsShutdownHandler;
  12. /**
  13. * @param callable $function
  14. *
  15. * @return void
  16. */
  17. public function registerShutdownFunction(callable $function)
  18. {
  19. $this->whoopsShutdownHandler = $function;
  20. register_shutdown_function([$this, 'handleShutdown']);
  21. }
  22. /**
  23. * Special case to deal with Fatal errors and the like.
  24. */
  25. public function handleShutdown()
  26. {
  27. $error = $this->getLastError();
  28. // Ignore core warnings and errors.
  29. if ($error && !($error['type'] & (E_CORE_WARNING | E_CORE_ERROR))) {
  30. $handler = $this->whoopsShutdownHandler;
  31. $handler();
  32. }
  33. }
  34. }