Skip to content

Commit

Permalink
fix: NotExposed generated operation should inherit resource options
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Aug 4, 2023
1 parent e274585 commit da0fd75
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
final class NotExposedOperationResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
{
use OperationDefaultsTrait;

public static $skolemUriTemplate = '/.well-known/genid/{id}';

private $linkFactory;
Expand Down Expand Up @@ -69,13 +71,13 @@ public function create(string $resourceClass): ResourceMetadataCollection
// No item operation has been found on all resources for resource class: generate one on the last resource
// Helpful to generate an IRI for a resource without declaring the Get operation
/** @var HttpOperation $operation */
$operation = (new NotExposed())->withClass($resource->getClass())->withShortName($resource->getShortName()); // @phpstan-ignore-line $resource is defined if count > 0
[$key, $operation] = $this->getOperationWithDefaults($resource, new NotExposed(), true); // @phpstan-ignore-line $resource is defined if count > 0

if (!$this->linkFactory->createLinksFromIdentifiers($operation)) {
$operation = $operation->withUriTemplate(self::$skolemUriTemplate);
}

$operations->add(sprintf('_api_%s_get', $operation->getShortName()), $operation)->sort(); // @phpstan-ignore-line $operation exists
$operations->add($key, $operation)->sort(); // @phpstan-ignore-line $operation exists

return $resourceMetadataCollection;
}
Expand Down

0 comments on commit da0fd75

Please sign in to comment.