ApiPlatform\Core\JsonLd\Action\ContextAction::__invoke PHP 메소드

__invoke() 공개 메소드

Generates a context according to the type requested.
public __invoke ( string $shortName ) : array
$shortName string string
리턴 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();
    }