HydraApi.php
public function getContext($exposedClassName)
    {
        $classes = $this->metadata->getAllMetadata();
        $metadata = null;

        foreach ($classes as $class) {
            if ($class->getExposeAs() === $exposedClassName) {
                $metadata = $class;
                break;
            }
        }

        if (null === $metadata) {
            return null;
        }

        $context = array(
            'hydra' => 'http://www.w3.org/ns/hydra/core#',
            'vocab' => $this->vocabUrl . '#'
        );

        $context[$exposedClassName] = ($metadata->isExternalReference())
            ? $metadata->getIri()
            : 'vocab:' . $metadata->getIri();

        foreach ($metadata->getProperties() as $property) {
            // If something is exposed as keyword, no context definition is necessary
            if (0 === strncmp($property->getExposeAs(), '@', 1)) {
                // TODO Make this check more reliable by just checking for actual keywords
                //      What should we do if we serialize to RDFa for instance?
                continue;
            }

            $termDefinition = ($property->isExternalReference())
                ? $property->getIri()
                : 'vocab:' . $property->getIri();

            // TODO Make this check more robust
            if ($property->getRoute()) {
                $termDefinition = array('@id' => $termDefinition, '@type' => '@id');
            } elseif ($this->hasNormalizer($property->getType())) {
                $normalizer = $this->getNormalizer($property->getType());
                $termDefinition = array('@id' => $termDefinition, '@type' => $normalizer->getTypeIri());
            }

            $context[$property->getExposeAs()] = $termDefinition;
        }

        return array('@context' => $context);
    }
public function getContext($exposedClassName)
    {
        $classes = $this->metadata->getAllMetadata();
        $metadata = null;

        foreach ($classes as $class) {
            if ($class->getExposeAs() === $exposedClassName) {
                $metadata = $class;
                break;
            }
        }

        if (null === $metadata) {
            return null;
        }

        $context = array(
            'hydra' => 'http://www.w3.org/ns/hydra/core#',
            'vocab' => $this->vocabUrl . '#'
        );

        $context[$exposedClassName] = ($metadata->isExternalReference())
            ? $metadata->getIri()
            : 'vocab:' . $metadata->getIri();

        foreach ($metadata->getProperties() as $property) {
            // If something is exposed as keyword, no context definition is necessary
            if (0 === strncmp($property->getExposeAs(), '@', 1)) {
                // TODO Make this check more reliable by just checking for actual keywords
                //      What should we do if we serialize to RDFa for instance?
                continue;
            }

            $termDefinition = ($property->isExternalReference())
                ? $property->getIri()
                : 'vocab:' . $property->getIri();

            // TODO Make this check more robust
            if ($property->getRoute()) {
                $termDefinition = array('@id' => $termDefinition, '@type' => '@id');
            } elseif ($this->hasNormalizer($property->getType())) {
                $normalizer = $this->getNormalizer($property->getType());
                $termDefinition = array('@id' => $termDefinition, '@type' => $normalizer->getTypeIri());
            }

            $context[$property->getExposeAs()] = $termDefinition;
        }

        return array('@context' => $context);
    }
Gets the context corresponding to the passed class

@param  string $exposedClassName The exposed class name

@return array|null The context in the form of an associative array or
null if no class is exposed with the specified
name.