Development

#3895: sfPropelFinder.php.patch

You must first sign up to be able to contribute.

Ticket #3895: sfPropelFinder.php.patch

File sfPropelFinder.php.patch, 1.5 kB (added by mrhyde, 6 months ago)
  • plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php

    old new  
    943943   
    944944  protected function findRelation($phpName, $peerClass) 
    945945  { 
     946    //first we need to build MapBuilder for related class 
     947    //so we can find TableMap in DatabaseMap 
     948    $mapBuilder = call_user_func(array($phpName.'Peer', 'getMapBuilder')); 
     949    if (!$mapBuilder->isBuilt()) 
     950    { 
     951      $mapBuilder->doBuild(); 
     952    } 
     953    $dbMap = Propel::getDatabaseMap(constant($peerClass.'::DATABASE_NAME')); 
    946954    foreach ($this->getColumnsForPeerClass($peerClass) as $c) 
    947955    { 
    948956      if ($c->isForeignKey()) 
    949957      { 
    950         if(sfInflector::camelize($c->getRelatedTableName()) == $phpName) 
     958        try 
    951959        { 
    952           return array( 
    953             constant($peerClass.'::'.$c->getColumnName()), 
    954             $c->getRelatedName() 
    955           ); 
     960          if ($dbMap->getTable($c->getRelatedTableName())->getPhpName() == $phpName) 
     961          { 
     962            return array( 
     963              constant($peerClass.'::'.$c->getColumnName()), 
     964              $c->getRelatedName() 
     965            ); 
     966          } 
    956967        } 
     968        catch (PropelException $ex) 
     969        { 
     970          // silence PropelException 
     971          // if we got here it means that the MapBuilder related to foreign key  
     972          // has not been built yet. 
     973        } 
    957974      } 
    958975    } 
    959976