ApiRoute.php 981 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\AppFramework\Http\Attribute;
  8. use Attribute;
  9. /**
  10. * This attribute can be used to define API routes on controller methods.
  11. *
  12. * It works in addition to the traditional routes.php method and has the same parameters
  13. * (except for the `name` parameter which is not needed).
  14. *
  15. * @since 29.0.0
  16. */
  17. #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
  18. class ApiRoute extends Route {
  19. /**
  20. * @inheritDoc
  21. *
  22. * @since 29.0.0
  23. */
  24. public function __construct(
  25. protected string $verb,
  26. protected string $url,
  27. protected ?array $requirements = null,
  28. protected ?array $defaults = null,
  29. protected ?string $root = null,
  30. protected ?string $postfix = null,
  31. ) {
  32. parent::__construct(
  33. Route::TYPE_API,
  34. $verb,
  35. $url,
  36. $requirements,
  37. $defaults,
  38. $root,
  39. $postfix,
  40. );
  41. }
  42. }