ApiPlatform\Core\Hydra\Serializer\DocumentationNormalizer::getHydraOperation PHP 메소드

getHydraOperation() 개인적인 메소드

Gets and populates if applicable a Hydra operation.
private getHydraOperation ( string $resourceClass, ResourceMetadata $resourceMetadata, string $operationName, array $operation, string $prefixedShortName, boolean $collection ) : array
$resourceClass string
$resourceMetadata ApiPlatform\Core\Metadata\Resource\ResourceMetadata
$operationName string
$operation array
$prefixedShortName string
$collection boolean
리턴 array
    private function getHydraOperation(string $resourceClass, ResourceMetadata $resourceMetadata, string $operationName, array $operation, string $prefixedShortName, bool $collection) : array
    {
        if ($collection) {
            $method = $this->operationMethodResolver->getCollectionOperationMethod($resourceClass, $operationName);
        } else {
            $method = $this->operationMethodResolver->getItemOperationMethod($resourceClass, $operationName);
        }
        $hydraOperation = $operation['hydra_context'] ?? [];
        $shortName = $resourceMetadata->getShortName();
        if ('GET' === $method && $collection) {
            $hydraOperation = ['hydra:title' => sprintf('Retrieves the collection of %s resources.', $shortName), 'returns' => 'hydra:PagedCollection'] + $hydraOperation;
        } elseif ('GET' === $method) {
            $hydraOperation = ['hydra:title' => sprintf('Retrieves %s resource.', $shortName), 'returns' => $prefixedShortName] + $hydraOperation;
        } elseif ('POST' === $method) {
            $hydraOperation = ['@type' => 'hydra:CreateResourceOperation', 'hydra:title' => sprintf('Creates a %s resource.', $shortName), 'returns' => $prefixedShortName, 'expects' => $prefixedShortName] + $hydraOperation;
        } elseif ('PUT' === $method) {
            $hydraOperation = ['@type' => 'hydra:ReplaceResourceOperation', 'hydra:title' => sprintf('Replaces the %s resource.', $shortName), 'returns' => $prefixedShortName, 'expects' => $prefixedShortName] + $hydraOperation;
        } elseif ('DELETE' === $method) {
            $hydraOperation = ['hydra:title' => sprintf('Deletes the %s resource.', $shortName), 'returns' => 'owl:Nothing'] + $hydraOperation;
        }
        $hydraOperation['@type'] ?? ($hydraOperation['@type'] = 'hydra:Operation');
        $hydraOperation['hydra:method'] ?? ($hydraOperation['hydra:method'] = $method);
        if (!isset($hydraOperation['rdfs:label']) && isset($hydraOperation['hydra:title'])) {
            $hydraOperation['rdfs:label'] = $hydraOperation['hydra:title'];
        }
        ksort($hydraOperation);
        return $hydraOperation;
    }