original_string: public function cors(ServerRequest $request, $allowedDomains = [], $allowedMethods = [], $allowedHeaders = [])
      {
          $origin = $request->getHeaderLine('Origin');
          $ssl = $request->is('ssl');
          $builder = new CorsBuilder($this, $origin, $ssl);
          if (!$origin) {
              return $builder;
          }
          if (empty($allowedDomains) && empty($allowedMethods) && empty($allowedHeaders)) {
              return $builder;
          }
          deprecationWarning(
              'The $allowedDomains, $allowedMethods, and $allowedHeaders parameters of Response::cors() ' .
              'are deprecated. Instead you should use the builder methods on the return of cors().'
          );
  
          $updated = $builder->allowOrigin($allowedDomains)
              ->allowMethods((array)$allowedMethods)
              ->allowHeaders((array)$allowedHeaders)
              ->build();
  
          // If $updated is a new instance, mutate this object in-place
          // to retain existing behavior.
          if ($updated !== $this) {
              foreach ($updated->getHeaders() as $name => $values) {
                  if (!$this->hasHeader($name)) {
                      $this->_setHeader($name, $values[0]);
                  }
              }
          }
  
          return $builder;
      }
code: public function cors(ServerRequest $request, $allowedDomains = [], $allowedMethods = [], $allowedHeaders = [])
      {
          $origin = $request->getHeaderLine('Origin');
          $ssl = $request->is('ssl');
          $builder = new CorsBuilder($this, $origin, $ssl);
          if (!$origin) {
              return $builder;
          }
          if (empty($allowedDomains) && empty($allowedMethods) && empty($allowedHeaders)) {
              return $builder;
          }
          deprecationWarning(
              'The $allowedDomains, $allowedMethods, and $allowedHeaders parameters of Response::cors() ' .
              'are deprecated. Instead you should use the builder methods on the return of cors().'
          );
  
          $updated = $builder->allowOrigin($allowedDomains)
              ->allowMethods((array)$allowedMethods)
              ->allowHeaders((array)$allowedHeaders)
              ->build();
  
          // If $updated is a new instance, mutate this object in-place
          // to retain existing behavior.
          if ($updated !== $this) {
              foreach ($updated->getHeaders() as $name => $values) {
                  if (!$this->hasHeader($name)) {
                      $this->_setHeader($name, $values[0]);
                  }
              }
          }
  
          return $builder;
      }
code_tokens: public function cors ( ServerRequest $ request , $ allowedDomains = [ ] , $ allowedMethods = [ ] , $ allowedHeaders = [ ] ) { $ origin = $ request -> getHeaderLine ( 'Origin' ) ; $ ssl = $ request -> is ( 'ssl' ) ; $ builder = new CorsBuilder ( $ this , $ origin , $ ssl ) ; if ( ! $ origin ) { return $ builder ; } if ( empty ( $ allowedDomains ) && empty ( $ allowedMethods ) && empty ( $ allowedHeaders ) ) { return $ builder ; } deprecationWarning ( 'The $allowedDomains, $allowedMethods, and $allowedHeaders parameters of Response::cors() ' . 'are deprecated. Instead you should use the builder methods on the return of cors().' ) ; $ updated = $ builder -> allowOrigin ( $ allowedDomains ) -> allowMethods ( ( array ) $ allowedMethods ) -> allowHeaders ( ( array ) $ allowedHeaders ) -> build ( ) ; // If $updated is a new instance, mutate this object in-place // to retain existing behavior. if ( $ updated !== $ this ) { foreach ( $ updated -> getHeaders ( ) as $ name => $ values ) { if ( ! $ this -> hasHeader ( $ name ) ) { $ this -> _setHeader ( $ name , $ values [ 0 ] ) ; } } } return $ builder ; }
docstring: Setup access for origin and methods on cross origin requests
  
  This method allow multiple ways to setup the domains, see the examples
  
  ### Full URI
  ```
  cors($request, 'https://www.cakephp.org');
  ```
  
  ### URI with wildcard
  ```
  cors($request, 'https://*.cakephp.org');
  ```
  
  ### Ignoring the requested protocol
  ```
  cors($request, 'www.cakephp.org');
  ```
  
  ### Any URI
  ```
  cors($request, '*');
  ```
  
  ### Whitelist of URIs
  ```
  cors($request, ['http://www.cakephp.org', '*.google.com', 'https://myproject.github.io']);
  ```
  
  *Note* The `$allowedDomains`, `$allowedMethods`, `$allowedHeaders` parameters are deprecated.
  Instead the builder object should be used.
  
  @param \Cake\Http\ServerRequest $request Request object
  @param string|array $allowedDomains List of allowed domains, see method description for more details
  @param string|array $allowedMethods List of HTTP verbs allowed
  @param string|array $allowedHeaders List of HTTP headers allowed
  @return \Cake\Http\CorsBuilder A builder object the provides a fluent interface for defining
  additional CORS headers.
docstring_tokens: Setup access for origin and methods on cross origin requests