UserApiController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace internship\controller;
  3. use n2n\web\http\controller\ControllerAdapter;
  4. use n2n\reflection\annotation\AnnoInit;
  5. use n2n\web\http\annotation\AnnoPath;
  6. use n2n\web\http\annotation\AnnoExt;
  7. class UserApiController extends ControllerAdapter {
  8. private static function _annos(AnnoInit $ai): void {
  9. //$ai->m('doDetail', new AnnoExt('txt'));
  10. $ai->m('modificationsInt', new AnnoPath('modInt?/paramInts+:#^[0-9]+$#'));
  11. $ai->m('modificationsString', new AnnoPath('modString?/params+:#^[a-z]+$#'));
  12. }
  13. /*
  14. * http://localhost/php-storm/internship-playground/src-php/public/user
  15. */
  16. public function index() {
  17. echo 'Hallo Welt!';
  18. }
  19. /*
  20. * http://localhost/php-storm/internship-playground/src-php/public/user/detail
  21. * http://localhost/php-storm/internship-playground/src-php/public/user/detail/Test
  22. * http://localhost/php-storm/internship-playground/src-php/public/user/detail/a/b/c
  23. */
  24. public function doDetail(?string $text1 = null, ?string $text2 = null, ?string $text3 = null) {
  25. echo "Hallo Welt! Detail Function " . $text1 . " " . $text2 . " " . $text3;
  26. }
  27. /*
  28. * http://localhost/php-storm/internship-playground/src-php/public/user/modInt/1/2/3
  29. */
  30. public function modificationsInt(array $paramInts) {
  31. echo 'params mod ints: ' . implode(', ', $paramInts);
  32. }
  33. /*
  34. * http://localhost/php-storm/internship-playground/src-php/public/user/modString/a/b/c
  35. */
  36. public function modificationsString(array $params) {
  37. echo 'params: ' . implode(', ', $params);
  38. }
  39. }