Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 2 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Events\Events;
  4. use CodeIgniter\Exceptions\FrameworkException;
  5. /*
  6. * --------------------------------------------------------------------
  7. * Application Events
  8. * --------------------------------------------------------------------
  9. * Events allow you to tap into the execution of the program without
  10. * modifying or extending core files. This file provides a central
  11. * location to define your events, though they can always be added
  12. * at run-time, also, if needed.
  13. *
  14. * You create code that can execute by subscribing to events with
  15. * the 'on()' method. This accepts any form of callable, including
  16. * Closures, that will be executed when the event is triggered.
  17. *
  18. * Example:
  19. * Events::on('create', [$myInstance, 'myMethod']);
  20. */
  21. Events::on('pre_system', static function () {
  22. if (ENVIRONMENT !== 'testing') {
  23. if (ini_get('zlib.output_compression')) {
  24. throw FrameworkException::forEnabledZlibOutputCompression();
  25. }
  26. while (ob_get_level() > 0) {
  27. ob_end_flush();
  28. }
  29. ob_start(static fn ($buffer) => $buffer);
  30. }
  31. /*
  32. * --------------------------------------------------------------------
  33. * Debug Toolbar Listeners.
  34. * --------------------------------------------------------------------
  35. * If you delete, they will no longer be collected.
  36. */
  37. if (CI_DEBUG && ! is_cli()) {
  38. Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
  39. Services::toolbar()->respond();
  40. }
  41. });