Ok, so here's what I ended up doing, might not be the best solution but
it works. I basically look in the cache config folder for
config_dbMap.php, if it doesn't exist I run the sfFinder and get the
array of files once, then write it to the config file. THis way the
fileFinder is only run when the cache is cleared and not everytime and
multiple times on one page.

Here's the replaced getRelatedClass()


public static function getRelatedClass($class, $middleClass)
  {
    $column = self::getRelatedColumn($class, $middleClass);

    $config_dbmap =
sfConfig::get('sf_config_cache_dir').'/config_dbMap.php';
    if (is_readable($config_dbmap))
    {
      require($config_dbmap);
    }
    else
    {
      $cache = new sfFileCache(sfConfig::get('sf_config_cache_dir'));
      $cache->setSuffix('');
      $classes =
sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs());

      foreach ($classes as $key=>$class)
      {
        $data[] = sprintf("'%s' => '%s',", $key, $class);
      }

      $data = sprintf("<?php\n".
                      "// auto-generated by sfPropelManyToMany\n".
                      "// date: %s\n\$classes = array(\n%s\n);\n",
                      date('Y/m/d H:i:s'), implode("\n", $data));

      $cache->set('config_dbMap.php', '', $data);
    }

    foreach ($classes as $class)
    {
      $class_map_builder = basename($class, '.php');
      $map = new $class_map_builder();
      $map->doBuild();
    }

    $tableMap = call_user_func(array($middleClass.'Peer',
'getTableMap'));

    return
$tableMap->getDatabaseMap()->getTable($column->getRelatedTableName())->getPhpName();
  }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs
-~----------~----~----~----~------~----~------~--~---

Reply via email to