vendor/api-platform/core/src/Metadata/Link.php line 17

  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;
  13. #[\Attribute(\Attribute::TARGET_PROPERTY \Attribute::TARGET_METHOD \Attribute::TARGET_PARAMETER)]
  14. final class Link extends Parameter
  15. {
  16.     public function __construct(
  17.         private ?string $parameterName null,
  18.         private ?string $fromProperty null,
  19.         private ?string $toProperty null,
  20.         private ?string $fromClass null,
  21.         private ?string $toClass null,
  22.         private ?array $identifiers null,
  23.         private ?bool $compositeIdentifier null,
  24.         private ?string $expandedValue null,
  25.         ?string $security null,
  26.         ?string $securityMessage null,
  27.         private ?string $securityObjectName null,
  28.         ?string $key null,
  29.         ?array $schema null,
  30.         ?OpenApi\Model\Parameter $openApi null,
  31.         mixed $provider null,
  32.         mixed $filter null,
  33.         ?string $property null,
  34.         ?string $description null,
  35.         ?bool $required null,
  36.         array $extraProperties = [],
  37.     ) {
  38.         // For the inverse property shortcut
  39.         if ($this->parameterName && class_exists($this->parameterName)) {
  40.             $this->fromClass $this->parameterName;
  41.         }
  42.         parent::__construct(
  43.             key$key,
  44.             schema$schema,
  45.             openApi$openApi,
  46.             provider$provider,
  47.             filter$filter,
  48.             property$property,
  49.             description$description,
  50.             required$required,
  51.             security$security,
  52.             securityMessage$securityMessage,
  53.             extraProperties$extraProperties
  54.         );
  55.     }
  56.     public function getParameterName(): ?string
  57.     {
  58.         return $this->parameterName;
  59.     }
  60.     public function withParameterName(string $parameterName): self
  61.     {
  62.         $self = clone $this;
  63.         $self->parameterName $parameterName;
  64.         return $self;
  65.     }
  66.     public function getFromClass(): ?string
  67.     {
  68.         return $this->fromClass;
  69.     }
  70.     public function withFromClass(string $fromClass): self
  71.     {
  72.         $self = clone $this;
  73.         $self->fromClass $fromClass;
  74.         return $self;
  75.     }
  76.     public function getToClass(): ?string
  77.     {
  78.         return $this->toClass;
  79.     }
  80.     public function withToClass(string $toClass): self
  81.     {
  82.         $self = clone $this;
  83.         $self->toClass $toClass;
  84.         return $self;
  85.     }
  86.     public function getFromProperty(): ?string
  87.     {
  88.         return $this->fromProperty;
  89.     }
  90.     public function withFromProperty(string $fromProperty): self
  91.     {
  92.         $self $this;
  93.         $self->fromProperty $fromProperty;
  94.         return $self;
  95.     }
  96.     public function getToProperty(): ?string
  97.     {
  98.         return $this->toProperty;
  99.     }
  100.     public function withToProperty(string $toProperty): self
  101.     {
  102.         $self = clone $this;
  103.         $self->toProperty $toProperty;
  104.         return $self;
  105.     }
  106.     public function getIdentifiers(): ?array
  107.     {
  108.         return $this->identifiers;
  109.     }
  110.     public function withIdentifiers(array $identifiers): self
  111.     {
  112.         $self = clone $this;
  113.         $self->identifiers $identifiers;
  114.         return $self;
  115.     }
  116.     public function getCompositeIdentifier(): ?bool
  117.     {
  118.         return $this->compositeIdentifier;
  119.     }
  120.     public function withCompositeIdentifier(bool $compositeIdentifier): self
  121.     {
  122.         $self = clone $this;
  123.         $self->compositeIdentifier $compositeIdentifier;
  124.         return $self;
  125.     }
  126.     public function getExpandedValue(): ?string
  127.     {
  128.         return $this->expandedValue;
  129.     }
  130.     public function withExpandedValue(string $expandedValue): self
  131.     {
  132.         $self = clone $this;
  133.         $self->expandedValue $expandedValue;
  134.         return $self;
  135.     }
  136.     public function getSecurity(): ?string
  137.     {
  138.         return $this->security;
  139.     }
  140.     public function getSecurityObjectName(): ?string
  141.     {
  142.         return $this->securityObjectName;
  143.     }
  144.     public function withSecurityObjectName(?string $securityObjectName): self
  145.     {
  146.         $self = clone $this;
  147.         $self->securityObjectName $securityObjectName;
  148.         return $self;
  149.     }
  150.     public function withLink(self $link): self
  151.     {
  152.         $self = clone $this;
  153.         if (!$self->getToProperty() && ($toProperty $link->getToProperty())) {
  154.             $self->toProperty $toProperty;
  155.         }
  156.         if (!$self->getCompositeIdentifier() && ($compositeIdentifier $link->getCompositeIdentifier())) {
  157.             $self->compositeIdentifier $compositeIdentifier;
  158.         }
  159.         if (!$self->getFromClass() && ($fromClass $link->getFromClass())) {
  160.             $self->fromClass $fromClass;
  161.         }
  162.         if (!$self->getToClass() && ($toClass $link->getToClass())) {
  163.             $self->toClass $toClass;
  164.         }
  165.         if (!$self->getIdentifiers() && ($identifiers $link->getIdentifiers())) {
  166.             $self->identifiers $identifiers;
  167.         }
  168.         if (!$self->getFromProperty() && ($fromProperty $link->getFromProperty())) {
  169.             $self->fromProperty $fromProperty;
  170.         }
  171.         if (!$self->getParameterName() && ($parameterName $link->getParameterName())) {
  172.             $self->parameterName $parameterName;
  173.         }
  174.         if (!$self->getExpandedValue() && ($expandedValue $link->getExpandedValue())) {
  175.             $self->expandedValue $expandedValue;
  176.         }
  177.         if (!$self->getSecurity() && ($security $link->getSecurity())) {
  178.             $self->security $security;
  179.         }
  180.         if (!$self->getSecurityMessage() && ($securityMessage $link->getSecurityMessage())) {
  181.             $self->securityMessage $securityMessage;
  182.         }
  183.         if (!$self->getSecurityObjectName() && ($securityObjectName $link->getSecurityObjectName())) {
  184.             $self->securityObjectName $securityObjectName;
  185.         }
  186.         return $self;
  187.     }
  188. }