original_string: public function getNonces(Request $request, Response $response)
      {
          if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) {
              return [
                  'csp_script_nonce' => $request->headers->get('X-SymfonyProfiler-Script-Nonce'),
                  'csp_style_nonce' => $request->headers->get('X-SymfonyProfiler-Style-Nonce'),
              ];
          }
  
          if ($response->headers->has('X-SymfonyProfiler-Script-Nonce') && $response->headers->has('X-SymfonyProfiler-Style-Nonce')) {
              return [
                  'csp_script_nonce' => $response->headers->get('X-SymfonyProfiler-Script-Nonce'),
                  'csp_style_nonce' => $response->headers->get('X-SymfonyProfiler-Style-Nonce'),
              ];
          }
  
          $nonces = [
              'csp_script_nonce' => $this->generateNonce(),
              'csp_style_nonce' => $this->generateNonce(),
          ];
  
          $response->headers->set('X-SymfonyProfiler-Script-Nonce', $nonces['csp_script_nonce']);
          $response->headers->set('X-SymfonyProfiler-Style-Nonce', $nonces['csp_style_nonce']);
  
          return $nonces;
      }
code: public function getNonces(Request $request, Response $response)
      {
          if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) {
              return [
                  'csp_script_nonce' => $request->headers->get('X-SymfonyProfiler-Script-Nonce'),
                  'csp_style_nonce' => $request->headers->get('X-SymfonyProfiler-Style-Nonce'),
              ];
          }
  
          if ($response->headers->has('X-SymfonyProfiler-Script-Nonce') && $response->headers->has('X-SymfonyProfiler-Style-Nonce')) {
              return [
                  'csp_script_nonce' => $response->headers->get('X-SymfonyProfiler-Script-Nonce'),
                  'csp_style_nonce' => $response->headers->get('X-SymfonyProfiler-Style-Nonce'),
              ];
          }
  
          $nonces = [
              'csp_script_nonce' => $this->generateNonce(),
              'csp_style_nonce' => $this->generateNonce(),
          ];
  
          $response->headers->set('X-SymfonyProfiler-Script-Nonce', $nonces['csp_script_nonce']);
          $response->headers->set('X-SymfonyProfiler-Style-Nonce', $nonces['csp_style_nonce']);
  
          return $nonces;
      }
code_tokens: public function getNonces ( Request $ request , Response $ response ) { if ( $ request -> headers -> has ( 'X-SymfonyProfiler-Script-Nonce' ) && $ request -> headers -> has ( 'X-SymfonyProfiler-Style-Nonce' ) ) { return [ 'csp_script_nonce' => $ request -> headers -> get ( 'X-SymfonyProfiler-Script-Nonce' ) , 'csp_style_nonce' => $ request -> headers -> get ( 'X-SymfonyProfiler-Style-Nonce' ) , ] ; } if ( $ response -> headers -> has ( 'X-SymfonyProfiler-Script-Nonce' ) && $ response -> headers -> has ( 'X-SymfonyProfiler-Style-Nonce' ) ) { return [ 'csp_script_nonce' => $ response -> headers -> get ( 'X-SymfonyProfiler-Script-Nonce' ) , 'csp_style_nonce' => $ response -> headers -> get ( 'X-SymfonyProfiler-Style-Nonce' ) , ] ; } $ nonces = [ 'csp_script_nonce' => $ this -> generateNonce ( ) , 'csp_style_nonce' => $ this -> generateNonce ( ) , ] ; $ response -> headers -> set ( 'X-SymfonyProfiler-Script-Nonce' , $ nonces [ 'csp_script_nonce' ] ) ; $ response -> headers -> set ( 'X-SymfonyProfiler-Style-Nonce' , $ nonces [ 'csp_style_nonce' ] ) ; return $ nonces ; }
docstring: Returns an array of nonces to be used in Twig templates and Content-Security-Policy headers.
  
  Nonce can be provided by;
  - The request - In case HTML content is fetched via AJAX and inserted in DOM, it must use the same nonce as origin
  - The response -  A call to getNonces() has already been done previously. Same nonce are returned
  - They are otherwise randomly generated
  
  @return array
docstring_tokens: Returns an array of nonces to be used in Twig templates and Content - Security - Policy headers .