private function getOptionResponse(GraphRequest $request)
 {
     $res = new GraphResponse();
     $res->setStatusCode(200);
     $res->setHeader('allow', 'HEAD,GET,POST,PUT,PATCH,DELETE,OPTIONS');
     return $res;
 }
 /**
  * Invia una risposta al client in base a un istanza di GraphResponse
  *
  * @param GraphResponse $response
  */
 private function sendResponse(GraphResponse $response)
 {
     $this->supportCors();
     http_response_code($response->getStatusCode());
     $h = $response->getHeaders();
     foreach ($h as $khdr => $hdr) {
         header($khdr . ': ' . $hdr);
     }
     //$this->supportCors();
     if ($response->getMedia() !== null) {
         // open the file in a binary mode
         $name = $response->getMedia();
         $fp = fopen($name, 'rb');
         fpassthru($fp);
     } else {
         print json_encode($response->getData(), JSON_PRETTY_PRINT);
     }
 }
 /**
  * Crea una risposta sicura (Modulo non trovato se non e pervenuta una
  * risposta)
  *
  * @param  GraphResponse | null $response
  * @return GraphResponse
  */
 private function getSafeResponse($response)
 {
     $filterManager = Graphene::getInstance()->getFilterManager();
     if ($response === null) {
         $response = new GraphResponse();
         $response->setHeader('content-type', 'application/json');
         if ($filterManager->haveErrors()) {
             $response->setBody($filterManager->serializeErrors());
             $ff = $filterManager->getFailedFilter();
             $response->setBody(json_encode(array("error" => array("message" => '[' . $ff['name'] . '] ' . $ff['message'], "code" => $ff['status'])), JSON_PRETTY_PRINT));
             $response->setStatusCode($ff['status']);
         } else {
             $response->setBody(json_encode(array("error" => array("message" => "action not found", "code" => "400")), JSON_PRETTY_PRINT));
             $response->setStatusCode(400);
         }
     }
     return $response;
 }