Scribe.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Knuckles\Scribe;
  3. use Knuckles\Camel\Extraction\ExtractedEndpointData;
  4. use Knuckles\Scribe\Tools\Globals;
  5. use Symfony\Component\HttpFoundation\Request;
  6. class Scribe
  7. {
  8. /**
  9. * Specify a callback that will be executed just before a response call is made
  10. * (after configuring the environment and starting a transaction).
  11. *
  12. * @param callable(Request, ExtractedEndpointData): mixed $callable
  13. */
  14. public static function beforeResponseCall(callable $callable)
  15. {
  16. Globals::$beforeResponseCall = $callable;
  17. }
  18. /**
  19. * Specify a callback that will be executed when Scribe is done generating your docs.
  20. * This callback will receive a map of all the output paths generated, that looks like this:
  21. * [
  22. * 'postman' => '/absolute/path/to/postman/collection',
  23. * 'openapi' => '/absolute/path/to/openapi/spec',
  24. * // If you're using `laravel` type, `html` will be null, and vice versa for `blade`.
  25. * 'html' => '/absolute/path/to/index.html/',
  26. * 'blade' => '/absolute/path/to/blade/view',
  27. * // These are paths to asset folders
  28. * 'assets' => [
  29. * 'js' => '/path/to/js/assets/folder',
  30. * 'css' => '/path/to/css/assets/folder',
  31. * 'images' => '/path/to/images/assets/folder',
  32. * ]
  33. * ]
  34. *
  35. * If you disabled `postman` or `openapi`, their values will be null.
  36. *
  37. * @param callable(array): mixed $callable
  38. */
  39. public static function afterGenerating(callable $callable)
  40. {
  41. Globals::$afterGenerating = $callable;
  42. }
  43. }