original_string: public function serve($path, SymfonyRequest $request, $disposition = 'inline', $fileName = null, $prepared = true)
      {
          if (! file_exists($path)) {
              return new Response('File Not Found', 404);
          } else if (! is_readable($path)) {
              return new Response('Unauthorized Access', 403);
          }
  
          // Create a Binary File Response instance.
          $headers = array(
              'Access-Control-Allow-Origin' => '*',
          );
  
          $mimeType = $this->guessMimeType($path);
  
          if ($request->getMethod() == 'OPTIONS') {
              $headers = array_merge($headers, array(
                  'Access-Control-Allow-Methods' => 'GET, HEAD, OPTIONS',
                  'Access-Control-Allow-Headers' => 'Content-Type, X-Auth-Token, Origin',
              ));
  
              return new Response('OK', 200, $headers);
          }
  
          // Not an OPTIONS request.
          else {
              $headers['Content-Type'] = $mimeType;
          }
  
          if ($mimeType !== 'application/json') {
              $response = new BinaryFileResponse($path, 200, $headers, true, $disposition, true, false);
  
              // Set the Content Disposition.
              $response->setContentDisposition($disposition, $fileName ?: basename($path));
  
              // Setup the (browser) Cache Control.
              $this->setupCacheControl($response);
  
              // Setup the Not Modified since...
              $response->isNotModified($request);
          } else {
              // We will do a special processing for the JSON files.
              $response = new JsonResponse(
                  json_decode(file_get_contents($path), true), 200, $headers
              );
          }
  
          // Prepare the Response against the Request instance, if is requested.
          if ($prepared) {
              return $response->prepare($request);
          }
  
          return $response;
      }
code: public function serve($path, SymfonyRequest $request, $disposition = 'inline', $fileName = null, $prepared = true)
      {
          if (! file_exists($path)) {
              return new Response('File Not Found', 404);
          } else if (! is_readable($path)) {
              return new Response('Unauthorized Access', 403);
          }
  
          // Create a Binary File Response instance.
          $headers = array(
              'Access-Control-Allow-Origin' => '*',
          );
  
          $mimeType = $this->guessMimeType($path);
  
          if ($request->getMethod() == 'OPTIONS') {
              $headers = array_merge($headers, array(
                  'Access-Control-Allow-Methods' => 'GET, HEAD, OPTIONS',
                  'Access-Control-Allow-Headers' => 'Content-Type, X-Auth-Token, Origin',
              ));
  
              return new Response('OK', 200, $headers);
          }
  
          // Not an OPTIONS request.
          else {
              $headers['Content-Type'] = $mimeType;
          }
  
          if ($mimeType !== 'application/json') {
              $response = new BinaryFileResponse($path, 200, $headers, true, $disposition, true, false);
  
              // Set the Content Disposition.
              $response->setContentDisposition($disposition, $fileName ?: basename($path));
  
              // Setup the (browser) Cache Control.
              $this->setupCacheControl($response);
  
              // Setup the Not Modified since...
              $response->isNotModified($request);
          } else {
              // We will do a special processing for the JSON files.
              $response = new JsonResponse(
                  json_decode(file_get_contents($path), true), 200, $headers
              );
          }
  
          // Prepare the Response against the Request instance, if is requested.
          if ($prepared) {
              return $response->prepare($request);
          }
  
          return $response;
      }
code_tokens: public function serve ( $ path , SymfonyRequest $ request , $ disposition = 'inline' , $ fileName = null , $ prepared = true ) { if ( ! file_exists ( $ path ) ) { return new Response ( 'File Not Found' , 404 ) ; } else if ( ! is_readable ( $ path ) ) { return new Response ( 'Unauthorized Access' , 403 ) ; } // Create a Binary File Response instance. $ headers = array ( 'Access-Control-Allow-Origin' => '*' , ) ; $ mimeType = $ this -> guessMimeType ( $ path ) ; if ( $ request -> getMethod ( ) == 'OPTIONS' ) { $ headers = array_merge ( $ headers , array ( 'Access-Control-Allow-Methods' => 'GET, HEAD, OPTIONS' , 'Access-Control-Allow-Headers' => 'Content-Type, X-Auth-Token, Origin' , ) ) ; return new Response ( 'OK' , 200 , $ headers ) ; } // Not an OPTIONS request. else { $ headers [ 'Content-Type' ] = $ mimeType ; } if ( $ mimeType !== 'application/json' ) { $ response = new BinaryFileResponse ( $ path , 200 , $ headers , true , $ disposition , true , false ) ; // Set the Content Disposition. $ response -> setContentDisposition ( $ disposition , $ fileName ? : basename ( $ path ) ) ; // Setup the (browser) Cache Control. $ this -> setupCacheControl ( $ response ) ; // Setup the Not Modified since... $ response -> isNotModified ( $ request ) ; } else { // We will do a special processing for the JSON files. $ response = new JsonResponse ( json_decode ( file_get_contents ( $ path ) , true ) , 200 , $ headers ) ; } // Prepare the Response against the Request instance, if is requested. if ( $ prepared ) { return $ response -> prepare ( $ request ) ; } return $ response ; }
docstring: Serve a File.
  
  @param  string  $path
  @param  \Symfony\Component\HttpFoundation\Request  $request
  @param  string  $disposition
  @param  string|null  $fileName
  @param  bool  $prepared
  
  @return  \Symfony\Component\HttpFoundation\Response
docstring_tokens: Serve a File .