ApiPlatform\Core\JsonLd\Action\ContextAction::__invoke PHP Method

__invoke() public method

Generates a context according to the type requested.
public __invoke ( string $shortName ) : array
$shortName string string
return array
    public function __invoke(string $shortName) : array
    {
        if ('Entrypoint' === $shortName) {
            return ['@context' => $this->contextBuilder->getEntrypointContext()];
        }
        if (isset(self::RESERVED_SHORT_NAMES[$shortName])) {
            return ['@context' => $this->contextBuilder->getBaseContext()];
        }
        foreach ($this->resourceNameCollectionFactory->create() as $resourceClass) {
            $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
            if ($shortName === $resourceMetadata->getShortName()) {
                return ['@context' => $this->contextBuilder->getResourceContext($resourceClass)];
            }
        }
        throw new NotFoundHttpException();
    }