Normal.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace EasySwoole\HttpAnnotation\Tests\TestController;
  3. use EasySwoole\Component\Di;
  4. use EasySwoole\Http\AbstractInterface\Controller;
  5. class Normal extends Controller
  6. {
  7. public $gc = 1;
  8. function index()
  9. {
  10. $this->gc = time();
  11. $this->response()->write('index');
  12. }
  13. protected function onRequest(?string $action): ?bool
  14. {
  15. if($action == 'testOnRequest'){
  16. $this->response()->write('testOnRequest');
  17. return false;
  18. }
  19. return true;
  20. }
  21. function afterAction(?string $actionName): void
  22. {
  23. Di::getInstance()->set("afterAction",'afterAction');
  24. }
  25. protected function noneAction()
  26. {
  27. $this->response()->write('noneAction');
  28. }
  29. function actionNotFound(?string $action)
  30. {
  31. $this->response()->write(404);
  32. }
  33. function exception()
  34. {
  35. $this->gc = time();
  36. new AAAAAAAAAAA();
  37. }
  38. protected function classParser()
  39. {
  40. $class = Annotation::class;
  41. if($class){
  42. $this->response()->write($class);
  43. }
  44. $this->response()->write('none');
  45. }
  46. protected function onException(\Throwable $throwable): void
  47. {
  48. $this->response()->write('exception');
  49. }
  50. }