/**
   * Generates classes and templates in cache.
   *
   * @param array The parameters
   *
   * @return string The data to put in configuration cache
   */
  public function generate($params = array())
  {
    if (!isset($params['model_class']))
    {
      $error = 'You must specify a "model_class"';
      $error = sprintf($error, $entry);

      throw new sfParseException($error);
    }
    $modelClass = $params['model_class'];
    if (!class_exists($modelClass))
    {
      $error = 'Unable to scaffold unexistant model "%s"';
      $error = sprintf($error, $modelClass);

      throw new sfInitializationException($error);
    }
    
    list($generatorClass, $type) = DbFinderAdapterUtils::getGenerator($modelClass);
    $this->generator = new $generatorClass($this->generatorManager);
    $this->orm = $type;

    // Manual initialization required for symfony 1.0
    $this->generator->initialize($this->generatorManager);
    $this->generator->setGeneratorClass('DbFinderAdmin');
    $this->generator->DbFinderAdminGenerator = $this;
    
    return $this->generator->generate($params);
  }