public function content($entity_type, $bundle, Request $request) {

    // TODO: expose cached/not cached through
    // more varied HTTP response codes.
    try {
      $context = $this->jsonldContextGenerator->getContext("$entity_type.$bundle");
      $response = new CacheableJsonResponse(json_decode($context), 200);
      $response->setEncodingOptions(JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
      $response->headers->set('Content-Type', 'application/ld+json');

      // For now deal with Cache dependencies manually.
      $meta = new CacheableMetadata();
      $meta->setCacheContexts(['user.permissions', 'ip', 'url']);
      $meta->setCacheTags(RdfMapping::load("$entity_type.$bundle")->getCacheTags());
      $meta->setCacheMaxAge(Cache::PERMANENT);
      $response->addCacheableDependency($meta);
    }
    catch (\Exception $e) {
      $response = new Response($e->getMessage(), 400);
    }

    return $response;
  }
public function content($entity_type, $bundle, Request $request) {

    // TODO: expose cached/not cached through
    // more varied HTTP response codes.
    try {
      $context = $this->jsonldContextGenerator->getContext("$entity_type.$bundle");
      $response = new CacheableJsonResponse(json_decode($context), 200);
      $response->setEncodingOptions(JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
      $response->headers->set('Content-Type', 'application/ld+json');

      // For now deal with Cache dependencies manually.
      $meta = new CacheableMetadata();
      $meta->setCacheContexts(['user.permissions', 'ip', 'url']);
      $meta->setCacheTags(RdfMapping::load("$entity_type.$bundle")->getCacheTags());
      $meta->setCacheMaxAge(Cache::PERMANENT);
      $response->addCacheableDependency($meta);
    }
    catch (\Exception $e) {
      $response = new Response($e->getMessage(), 400);
    }

    return $response;
  }
public function content ( $ entity_type , $ bundle , Request $ request ) { // TODO: expose cached/not cached through // more varied HTTP response codes. try { $ context = $ this -> jsonldContextGenerator -> getContext ( "$entity_type.$bundle" ) ; $ response = new CacheableJsonResponse ( json_decode ( $ context ) , 200 ) ; $ response -> setEncodingOptions ( JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK ) ; $ response -> headers -> set ( 'Content-Type' , 'application/ld+json' ) ; // For now deal with Cache dependencies manually. $ meta = new CacheableMetadata ( ) ; $ meta -> setCacheContexts ( [ 'user.permissions' , 'ip' , 'url' ] ) ; $ meta -> setCacheTags ( RdfMapping :: load ( "$entity_type.$bundle" ) -> getCacheTags ( ) ) ; $ meta -> setCacheMaxAge ( Cache :: PERMANENT ) ; $ response -> addCacheableDependency ( $ meta ) ; } catch ( \ Exception $ e ) { $ response = new Response ( $ e -> getMessage ( ) , 400 ) ; } return $ response ; }
Returns an JSON-LD Context for a entity bundle.

@param string $entity_type
Route argument, an entity type.
@param string $bundle
Route argument, a bundle.
@param \Symfony\Component\HttpFoundation\Request $request
The Symfony Http Request.

@return \Symfony\Component\HttpFoundation\Response
An Http response.
Returns an JSON - LD Context for a entity bundle .