original_string: public function webroot($file)
      {
          $request = $this->_View->getRequest();
  
          $asset = explode('?', $file);
          $asset[1] = isset($asset[1]) ? '?' . $asset[1] : null;
          $webPath = $request->getAttribute('webroot') . $asset[0];
          $file = $asset[0];
  
          if (!empty($this->_View->getTheme())) {
              $file = trim($file, '/');
              $theme = $this->_inflectThemeName($this->_View->getTheme()) . '/';
  
              if (DIRECTORY_SEPARATOR === '\\') {
                  $file = str_replace('/', '\\', $file);
              }
  
              if (file_exists(Configure::read('App.wwwRoot') . $theme . $file)) {
                  $webPath = $request->getAttribute('webroot') . $theme . $asset[0];
              } else {
                  $themePath = Plugin::path($this->_View->getTheme());
                  $path = $themePath . 'webroot/' . $file;
                  if (file_exists($path)) {
                      $webPath = $request->getAttribute('webroot') . $theme . $asset[0];
                  }
              }
          }
          if (strpos($webPath, '//') !== false) {
              return str_replace('//', '/', $webPath . $asset[1]);
          }
  
          return $webPath . $asset[1];
      }
code: public function webroot($file)
      {
          $request = $this->_View->getRequest();
  
          $asset = explode('?', $file);
          $asset[1] = isset($asset[1]) ? '?' . $asset[1] : null;
          $webPath = $request->getAttribute('webroot') . $asset[0];
          $file = $asset[0];
  
          if (!empty($this->_View->getTheme())) {
              $file = trim($file, '/');
              $theme = $this->_inflectThemeName($this->_View->getTheme()) . '/';
  
              if (DIRECTORY_SEPARATOR === '\\') {
                  $file = str_replace('/', '\\', $file);
              }
  
              if (file_exists(Configure::read('App.wwwRoot') . $theme . $file)) {
                  $webPath = $request->getAttribute('webroot') . $theme . $asset[0];
              } else {
                  $themePath = Plugin::path($this->_View->getTheme());
                  $path = $themePath . 'webroot/' . $file;
                  if (file_exists($path)) {
                      $webPath = $request->getAttribute('webroot') . $theme . $asset[0];
                  }
              }
          }
          if (strpos($webPath, '//') !== false) {
              return str_replace('//', '/', $webPath . $asset[1]);
          }
  
          return $webPath . $asset[1];
      }
code_tokens: public function webroot ( $ file ) { $ request = $ this -> _View -> getRequest ( ) ; $ asset = explode ( '?' , $ file ) ; $ asset [ 1 ] = isset ( $ asset [ 1 ] ) ? '?' . $ asset [ 1 ] : null ; $ webPath = $ request -> getAttribute ( 'webroot' ) . $ asset [ 0 ] ; $ file = $ asset [ 0 ] ; if ( ! empty ( $ this -> _View -> getTheme ( ) ) ) { $ file = trim ( $ file , '/' ) ; $ theme = $ this -> _inflectThemeName ( $ this -> _View -> getTheme ( ) ) . '/' ; if ( DIRECTORY_SEPARATOR === '\\' ) { $ file = str_replace ( '/' , '\\' , $ file ) ; } if ( file_exists ( Configure :: read ( 'App.wwwRoot' ) . $ theme . $ file ) ) { $ webPath = $ request -> getAttribute ( 'webroot' ) . $ theme . $ asset [ 0 ] ; } else { $ themePath = Plugin :: path ( $ this -> _View -> getTheme ( ) ) ; $ path = $ themePath . 'webroot/' . $ file ; if ( file_exists ( $ path ) ) { $ webPath = $ request -> getAttribute ( 'webroot' ) . $ theme . $ asset [ 0 ] ; } } } if ( strpos ( $ webPath , '//' ) !== false ) { return str_replace ( '//' , '/' , $ webPath . $ asset [ 1 ] ) ; } return $ webPath . $ asset [ 1 ] ; }
docstring: Checks if a file exists when theme is used, if no file is found default location is returned
  
  @param string $file The file to create a webroot path to.
  @return string Web accessible path to file.
docstring_tokens: Checks if a file exists when theme is used if no file is found default location is returned