code: function() {
  
          var candidates = this.layers || this.map.layers;
          var layers = [];
          var layer, url;
          for(var i = candidates.length - 1; i >= 0; --i) {
              layer = candidates[i];
              if(layer instanceof OpenLayers.Layer.WMS &&
                 (!this.queryVisible || layer.getVisibility())) {
                  url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;
                  // if the control was not configured with a url, set it
                  // to the first layer url
                  if(this.drillDown === false && !this.url) {
                      this.url = url;
                  }
                  if(this.drillDown === true || this.urlMatches(url)) {
                      layers.push(layer);
                  }
              }
          }
          return layers;
      }
docs: Method: findLayers
  Internal method to get the layers, independent of whether we are
  inspecting the map or using a client-provided array