src/Graviton/RestBundle/Controller/RestController.php
public function schemaAction(Request $request, $id = null)
    {
        $request->attributes->set('schemaRequest', true);

        list($app, $module, , $modelName, $schemaType) = explode('.', $request->attributes->get('_route'));

        $response = $this->response;
        $response->setStatusCode(Response::HTTP_OK);
        $response->setVary(['Origin', 'Accept-Encoding']);
        $response->setPublic();

        if (!$id && $schemaType != 'canonicalIdSchema') {
            $schema = $this->schemaUtils->getCollectionSchema($modelName, $this->getModel());
        } else {
            $schema = $this->schemaUtils->getModelSchema($modelName, $this->getModel());
        }

        // enabled methods for CorsListener
        $corsMethods = 'GET, POST, PUT, PATCH, DELETE, OPTIONS';
        try {
            $router = $this->getRouter();
            // if post route is available we assume everything is readable
            $router->generate(implode('.', array($app, $module, 'rest', $modelName, 'post')));
        } catch (RouteNotFoundException $exception) {
            // only allow read methods
            $corsMethods = 'GET, OPTIONS';
        }

        $request->attributes->set('corsMethods', $corsMethods);
        $response->setContent($this->restUtils->serialize($schema));

        return $response;
    }
public function schemaAction(Request $request, $id = null)
    {
        $request->attributes->set('schemaRequest', true);

        list($app, $module, , $modelName, $schemaType) = explode('.', $request->attributes->get('_route'));

        $response = $this->response;
        $response->setStatusCode(Response::HTTP_OK);
        $response->setVary(['Origin', 'Accept-Encoding']);
        $response->setPublic();

        if (!$id && $schemaType != 'canonicalIdSchema') {
            $schema = $this->schemaUtils->getCollectionSchema($modelName, $this->getModel());
        } else {
            $schema = $this->schemaUtils->getModelSchema($modelName, $this->getModel());
        }

        // enabled methods for CorsListener
        $corsMethods = 'GET, POST, PUT, PATCH, DELETE, OPTIONS';
        try {
            $router = $this->getRouter();
            // if post route is available we assume everything is readable
            $router->generate(implode('.', array($app, $module, 'rest', $modelName, 'post')));
        } catch (RouteNotFoundException $exception) {
            // only allow read methods
            $corsMethods = 'GET, OPTIONS';
        }

        $request->attributes->set('corsMethods', $corsMethods);
        $response->setContent($this->restUtils->serialize($schema));

        return $response;
    }
public function schemaAction ( Request $ request , $ id = null ) { $ request -> attributes -> set ( 'schemaRequest' , true ) ; list ( $ app , $ module , , $ modelName , $ schemaType ) = explode ( '.' , $ request -> attributes -> get ( '_route' ) ) ; $ response = $ this -> response ; $ response -> setStatusCode ( Response :: HTTP_OK ) ; $ response -> setVary ( [ 'Origin' , 'Accept-Encoding' ] ) ; $ response -> setPublic ( ) ; if ( ! $ id && $ schemaType != 'canonicalIdSchema' ) { $ schema = $ this -> schemaUtils -> getCollectionSchema ( $ modelName , $ this -> getModel ( ) ) ; } else { $ schema = $ this -> schemaUtils -> getModelSchema ( $ modelName , $ this -> getModel ( ) ) ; } // enabled methods for CorsListener $ corsMethods = 'GET, POST, PUT, PATCH, DELETE, OPTIONS' ; try { $ router = $ this -> getRouter ( ) ; // if post route is available we assume everything is readable $ router -> generate ( implode ( '.' , array ( $ app , $ module , 'rest' , $ modelName , 'post' ) ) ) ; } catch ( RouteNotFoundException $ exception ) { // only allow read methods $ corsMethods = 'GET, OPTIONS' ; } $ request -> attributes -> set ( 'corsMethods' , $ corsMethods ) ; $ response -> setContent ( $ this -> restUtils -> serialize ( $ schema ) ) ; return $ response ; }
Return schema GET results.

@param Request $request Current http request
@param string  $id      ID of record

@throws SerializationException
@return \Symfony\Component\HttpFoundation\Response $response Result of the action
Return schema GET results .