vendor/api-platform/core/src/Metadata/HttpOperation.php line 269

  1. <?php
  2. /*
  3.  * This file is part of the API Platform project.
  4.  *
  5.  * (c) Kévin Dunglas <dunglas@gmail.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace ApiPlatform\Metadata;
  12. use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
  13. use ApiPlatform\State\OptionsInterface;
  14. use Symfony\Component\WebLink\Link as WebLink;
  15. class HttpOperation extends Operation
  16. {
  17.     public const METHOD_GET 'GET';
  18.     public const METHOD_POST 'POST';
  19.     public const METHOD_PUT 'PUT';
  20.     public const METHOD_PATCH 'PATCH';
  21.     public const METHOD_DELETE 'DELETE';
  22.     public const METHOD_HEAD 'HEAD';
  23.     public const METHOD_OPTIONS 'OPTIONS';
  24.     /**
  25.      * @param string[]|null                                  $types         the RDF types of this property
  26.      * @param array<int|string, string|string[]>|string|null $formats       {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
  27.      * @param array<int|string, string|string[]>|string|null $inputFormats  {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
  28.      * @param array<int|string, string|string[]>|string|null $outputFormats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
  29.      * @param array<string,array{
  30.      *     0: string,
  31.      *     1: string
  32.      * }|array{
  33.      *     from_property?: string,
  34.      *     to_property?: string,
  35.      *     from_class?: string,
  36.      *     to_class?: string,
  37.      *     identifiers?: string[],
  38.      *     composite_identifier?: bool,
  39.      *     expanded_value?: string,
  40.      * }|Link>|string[]|string|null $uriVariables {@see https://api-platform.com/docs/core/subresources/}
  41.      * @param string|null     $routePrefix {@see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations}
  42.      * @param string|null     $sunset      {@see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed}
  43.      * @param string|int|null $status      {@see https://api-platform.com/docs/core/operations/#configuring-operations}
  44.      * @param array{
  45.      *     max_age?: int,
  46.      *     vary?: string|string[],
  47.      *     public?: bool,
  48.      *     shared_max_age?: int,
  49.      *     stale_while_revalidate?: int,
  50.      *     stale-if-error?: int,
  51.      * }|null $cacheHeaders {@see https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers}
  52.      * @param array{
  53.      *     field: string,
  54.      *     direction: string,
  55.      * }|null $paginationViaCursor {@see https://api-platform.com/docs/core/pagination/#cursor-based-pagination}
  56.      * @param array|null $normalizationContext   {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
  57.      * @param array|null $denormalizationContext {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
  58.      * @param array|null $hydraContext           {@see https://api-platform.com/docs/core/extending-jsonld-context/#hydra}
  59.      * @param array|null $openapiContext         {@see https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts}
  60.      * @param array{
  61.      *     class?: string|null,
  62.      *     name?: string,
  63.      * }|string|false|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
  64.      * @param array{
  65.      *     class?: string|null,
  66.      *     name?: string,
  67.      * }|string|false|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
  68.      * @param string|array|bool|null $mercure   {@see https://api-platform.com/docs/core/mercure}
  69.      * @param string|bool|null       $messenger {@see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus}
  70.      * @param string|callable|null   $provider  {@see https://api-platform.com/docs/core/state-providers/#state-providers}
  71.      * @param string|callable|null   $processor {@see https://api-platform.com/docs/core/state-processors/#state-processors}
  72.      * @param WebLink[]|null         $links
  73.      */
  74.     public function __construct(
  75.         protected string $method 'GET',
  76.         protected ?string $uriTemplate null,
  77.         protected ?array $types null,
  78.         protected $formats null,
  79.         protected $inputFormats null,
  80.         protected $outputFormats null,
  81.         protected $uriVariables null,
  82.         protected ?string $routePrefix null,
  83.         protected ?string $routeName null,
  84.         protected ?array $defaults null,
  85.         protected ?array $requirements null,
  86.         protected ?array $options null,
  87.         protected ?bool $stateless null,
  88.         /**
  89.          * The `sunset` option indicates when a deprecated operation will be removed.
  90.          *
  91.          * <div data-code-selector>
  92.          *
  93.          * ```php
  94.          * <?php
  95.          * // api/src/Entity/Parchment.php
  96.          * use ApiPlatform\Metadata\Get;
  97.          *
  98.          * #[Get(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
  99.          * class Parchment
  100.          * {
  101.          *     // ...
  102.          * }
  103.          * ```
  104.          *
  105.          * ```yaml
  106.          * # api/config/api_platform/resources.yaml
  107.          * resources:
  108.          *     App\Entity\Parchment:
  109.          *         - operations:
  110.          *               ApiPlatform\Metadata\Get:
  111.          *                   deprecationReason: 'Create a Book instead'
  112.          *                   sunset: '01/01/2020'
  113.          * ```
  114.          *
  115.          * ```xml
  116.          * <?xml version="1.0" encoding="UTF-8" ?>
  117.          * <!-- api/config/api_platform/resources.xml -->
  118.          *
  119.          * <resources
  120.          *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
  121.          *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  122.          *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
  123.          *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
  124.          *     <resource class="App\Entity\Parchment">
  125.          *         <operations>
  126.          *             <operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" sunset="01/01/2020" />
  127.          *         <operations>
  128.          *     </resource>
  129.          * </resources>
  130.          * ```
  131.          *
  132.          * </div>
  133.          */
  134.         protected ?string $sunset null,
  135.         protected ?string $acceptPatch null,
  136.         protected $status null,
  137.         protected ?string $host null,
  138.         protected ?array $schemes null,
  139.         protected ?string $condition null,
  140.         protected ?string $controller null,
  141.         protected ?array $cacheHeaders null,
  142.         protected ?array $paginationViaCursor null,
  143.         protected ?array $hydraContext null,
  144.         protected ?array $openapiContext null// TODO Remove in 4.0
  145.         protected bool|OpenApiOperation|null $openapi null,
  146.         protected ?array $exceptionToStatus null,
  147.         protected ?bool $queryParameterValidationEnabled null,
  148.         protected ?array $links null,
  149.         string $shortName null,
  150.         string $class null,
  151.         bool $paginationEnabled null,
  152.         string $paginationType null,
  153.         int $paginationItemsPerPage null,
  154.         int $paginationMaximumItemsPerPage null,
  155.         bool $paginationPartial null,
  156.         bool $paginationClientEnabled null,
  157.         bool $paginationClientItemsPerPage null,
  158.         bool $paginationClientPartial null,
  159.         bool $paginationFetchJoinCollection null,
  160.         bool $paginationUseOutputWalkers null,
  161.         array $order null,
  162.         string $description null,
  163.         array $normalizationContext null,
  164.         array $denormalizationContext null,
  165.         bool $collectDenormalizationErrors null,
  166.         string $security null,
  167.         string $securityMessage null,
  168.         string $securityPostDenormalize null,
  169.         string $securityPostDenormalizeMessage null,
  170.         string $securityPostValidation null,
  171.         string $securityPostValidationMessage null,
  172.         string $deprecationReason null,
  173.         array $filters null,
  174.         array $validationContext null,
  175.         $input null,
  176.         $output null,
  177.         $mercure null,
  178.         $messenger null,
  179.         bool $elasticsearch null,
  180.         int $urlGenerationStrategy null,
  181.         bool $read null,
  182.         bool $deserialize null,
  183.         bool $validate null,
  184.         bool $write null,
  185.         bool $serialize null,
  186.         bool $fetchPartial null,
  187.         bool $forceEager null,
  188.         int $priority null,
  189.         string $name null,
  190.         $provider null,
  191.         $processor null,
  192.         OptionsInterface $stateOptions null,
  193.         array $extraProperties = [],
  194.     ) {
  195.         parent::__construct(
  196.             shortName$shortName,
  197.             class: $class,
  198.             paginationEnabled$paginationEnabled,
  199.             paginationType$paginationType,
  200.             paginationItemsPerPage$paginationItemsPerPage,
  201.             paginationMaximumItemsPerPage$paginationMaximumItemsPerPage,
  202.             paginationPartial$paginationPartial,
  203.             paginationClientEnabled$paginationClientEnabled,
  204.             paginationClientItemsPerPage$paginationClientItemsPerPage,
  205.             paginationClientPartial$paginationClientPartial,
  206.             paginationFetchJoinCollection$paginationFetchJoinCollection,
  207.             paginationUseOutputWalkers$paginationUseOutputWalkers,
  208.             order$order,
  209.             description$description,
  210.             normalizationContext$normalizationContext,
  211.             denormalizationContext$denormalizationContext,
  212.             collectDenormalizationErrors$collectDenormalizationErrors,
  213.             security$security,
  214.             securityMessage$securityMessage,
  215.             securityPostDenormalize$securityPostDenormalize,
  216.             securityPostDenormalizeMessage$securityPostDenormalizeMessage,
  217.             securityPostValidation$securityPostValidation,
  218.             securityPostValidationMessage$securityPostValidationMessage,
  219.             deprecationReason$deprecationReason,
  220.             filters$filters,
  221.             validationContext$validationContext,
  222.             input$input,
  223.             output$output,
  224.             mercure$mercure,
  225.             messenger$messenger,
  226.             elasticsearch$elasticsearch,
  227.             urlGenerationStrategy$urlGenerationStrategy,
  228.             read$read,
  229.             deserialize$deserialize,
  230.             validate$validate,
  231.             write$write,
  232.             serialize$serialize,
  233.             fetchPartial$fetchPartial,
  234.             forceEager$forceEager,
  235.             priority$priority,
  236.             name$name,
  237.             provider$provider,
  238.             processor$processor,
  239.             stateOptions$stateOptions,
  240.             extraProperties$extraProperties
  241.         );
  242.     }
  243.     public function getMethod(): string
  244.     {
  245.         return $this->method;
  246.     }
  247.     public function withMethod(string $method): self
  248.     {
  249.         $self = clone $this;
  250.         $self->method $method;
  251.         return $self;
  252.     }
  253.     public function getUriTemplate(): ?string
  254.     {
  255.         return $this->uriTemplate;
  256.     }
  257.     public function withUriTemplate(string $uriTemplate null)
  258.     {
  259.         $self = clone $this;
  260.         $self->uriTemplate $uriTemplate;
  261.         return $self;
  262.     }
  263.     public function getTypes(): ?array
  264.     {
  265.         return $this->types;
  266.     }
  267.     /**
  268.      * @param string[]|string $types
  269.      */
  270.     public function withTypes($types): self
  271.     {
  272.         $self = clone $this;
  273.         $self->types = (array) $types;
  274.         return $self;
  275.     }
  276.     public function getFormats()
  277.     {
  278.         return $this->formats;
  279.     }
  280.     public function withFormats($formats null): self
  281.     {
  282.         $self = clone $this;
  283.         $self->formats $formats;
  284.         return $self;
  285.     }
  286.     public function getInputFormats()
  287.     {
  288.         return $this->inputFormats;
  289.     }
  290.     public function withInputFormats($inputFormats null): self
  291.     {
  292.         $self = clone $this;
  293.         $self->inputFormats $inputFormats;
  294.         return $self;
  295.     }
  296.     public function getOutputFormats()
  297.     {
  298.         return $this->outputFormats;
  299.     }
  300.     public function withOutputFormats($outputFormats null): self
  301.     {
  302.         $self = clone $this;
  303.         $self->outputFormats $outputFormats;
  304.         return $self;
  305.     }
  306.     public function getUriVariables()
  307.     {
  308.         return $this->uriVariables;
  309.     }
  310.     public function withUriVariables($uriVariables): self
  311.     {
  312.         $self = clone $this;
  313.         $self->uriVariables $uriVariables;
  314.         return $self;
  315.     }
  316.     public function getRoutePrefix(): ?string
  317.     {
  318.         return $this->routePrefix;
  319.     }
  320.     public function withRoutePrefix(string $routePrefix): self
  321.     {
  322.         $self = clone $this;
  323.         $self->routePrefix $routePrefix;
  324.         return $self;
  325.     }
  326.     public function getRouteName(): ?string
  327.     {
  328.         return $this->routeName;
  329.     }
  330.     public function withRouteName(?string $routeName): self
  331.     {
  332.         $self = clone $this;
  333.         $self->routeName $routeName;
  334.         return $self;
  335.     }
  336.     public function getDefaults(): ?array
  337.     {
  338.         return $this->defaults;
  339.     }
  340.     public function withDefaults(array $defaults): self
  341.     {
  342.         $self = clone $this;
  343.         $self->defaults $defaults;
  344.         return $self;
  345.     }
  346.     public function getRequirements(): ?array
  347.     {
  348.         return $this->requirements;
  349.     }
  350.     public function withRequirements(array $requirements): self
  351.     {
  352.         $self = clone $this;
  353.         $self->requirements $requirements;
  354.         return $self;
  355.     }
  356.     public function getOptions(): ?array
  357.     {
  358.         return $this->options;
  359.     }
  360.     public function withOptions(array $options): self
  361.     {
  362.         $self = clone $this;
  363.         $self->options $options;
  364.         return $self;
  365.     }
  366.     public function getStateless(): ?bool
  367.     {
  368.         return $this->stateless;
  369.     }
  370.     public function withStateless($stateless): self
  371.     {
  372.         $self = clone $this;
  373.         $self->stateless $stateless;
  374.         return $self;
  375.     }
  376.     public function getSunset(): ?string
  377.     {
  378.         return $this->sunset;
  379.     }
  380.     public function withSunset(string $sunset): self
  381.     {
  382.         $self = clone $this;
  383.         $self->sunset $sunset;
  384.         return $self;
  385.     }
  386.     public function getAcceptPatch(): ?string
  387.     {
  388.         return $this->acceptPatch;
  389.     }
  390.     public function withAcceptPatch(string $acceptPatch): self
  391.     {
  392.         $self = clone $this;
  393.         $self->acceptPatch $acceptPatch;
  394.         return $self;
  395.     }
  396.     public function getStatus(): ?int
  397.     {
  398.         return $this->status;
  399.     }
  400.     public function withStatus(int $status): self
  401.     {
  402.         $self = clone $this;
  403.         $self->status $status;
  404.         return $self;
  405.     }
  406.     public function getHost(): ?string
  407.     {
  408.         return $this->host;
  409.     }
  410.     public function withHost(string $host): self
  411.     {
  412.         $self = clone $this;
  413.         $self->host $host;
  414.         return $self;
  415.     }
  416.     public function getSchemes(): ?array
  417.     {
  418.         return $this->schemes;
  419.     }
  420.     public function withSchemes(array $schemes): self
  421.     {
  422.         $self = clone $this;
  423.         $self->schemes $schemes;
  424.         return $self;
  425.     }
  426.     public function getCondition(): ?string
  427.     {
  428.         return $this->condition;
  429.     }
  430.     public function withCondition(string $condition): self
  431.     {
  432.         $self = clone $this;
  433.         $self->condition $condition;
  434.         return $self;
  435.     }
  436.     public function getController(): ?string
  437.     {
  438.         return $this->controller;
  439.     }
  440.     public function withController(string $controller): self
  441.     {
  442.         $self = clone $this;
  443.         $self->controller $controller;
  444.         return $self;
  445.     }
  446.     public function getCacheHeaders(): ?array
  447.     {
  448.         return $this->cacheHeaders;
  449.     }
  450.     public function withCacheHeaders(array $cacheHeaders): self
  451.     {
  452.         $self = clone $this;
  453.         $self->cacheHeaders $cacheHeaders;
  454.         return $self;
  455.     }
  456.     public function getPaginationViaCursor(): ?array
  457.     {
  458.         return $this->paginationViaCursor;
  459.     }
  460.     public function withPaginationViaCursor(array $paginationViaCursor): self
  461.     {
  462.         $self = clone $this;
  463.         $self->paginationViaCursor $paginationViaCursor;
  464.         return $self;
  465.     }
  466.     public function getHydraContext(): ?array
  467.     {
  468.         return $this->hydraContext;
  469.     }
  470.     public function withHydraContext(array $hydraContext): self
  471.     {
  472.         $self = clone $this;
  473.         $self->hydraContext $hydraContext;
  474.         return $self;
  475.     }
  476.     public function getOpenapiContext(): ?array
  477.     {
  478.         return $this->openapiContext;
  479.     }
  480.     public function withOpenapiContext(array $openapiContext): self
  481.     {
  482.         $self = clone $this;
  483.         $self->openapiContext $openapiContext;
  484.         return $self;
  485.     }
  486.     public function getOpenapi(): bool|OpenApiOperation|null
  487.     {
  488.         return $this->openapi;
  489.     }
  490.     public function withOpenapi(bool|OpenApiOperation $openapi): self
  491.     {
  492.         $self = clone $this;
  493.         $self->openapi $openapi;
  494.         return $self;
  495.     }
  496.     public function getExceptionToStatus(): ?array
  497.     {
  498.         return $this->exceptionToStatus;
  499.     }
  500.     public function withExceptionToStatus(array $exceptionToStatus): self
  501.     {
  502.         $self = clone $this;
  503.         $self->exceptionToStatus $exceptionToStatus;
  504.         return $self;
  505.     }
  506.     public function getQueryParameterValidationEnabled(): ?bool
  507.     {
  508.         return $this->queryParameterValidationEnabled;
  509.     }
  510.     public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): self
  511.     {
  512.         $self = clone $this;
  513.         $self->queryParameterValidationEnabled $queryParameterValidationEnabled;
  514.         return $self;
  515.     }
  516.     public function getLinks(): ?array
  517.     {
  518.         return $this->links;
  519.     }
  520.     /**
  521.      * @param WebLink[] $links
  522.      */
  523.     public function withLinks(array $links): self
  524.     {
  525.         $self = clone $this;
  526.         $self->links $links;
  527.         return $self;
  528.     }
  529. }