Development

Changeset 7200

You must first sign up to be able to contribute.

Changeset 7200

Show
Ignore:
Timestamp:
01/28/08 02:00:36 (10 months ago)
Author:
dwhittle
Message:

dwhittle: merged propel changes to branch + fixed propel i18n

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php

    r7161 r7200  
    114114        foreach ($tblFK->getColumns() as $col) 
    115115        { 
    116           if (("true" === strtolower($col->getAttribute('isCulture')))) 
     116          if (('true' == trim(strtolower($col->getAttribute('isCulture'))))) 
    117117          { 
    118118            $culturePhpName = $col->getPhpName(); 
     
    160160 
    161161    ".$this->getPeerClassname()."::addSelectColumns(\$c); 
    162     \$startcol = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1
     162    \$startcol = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS)
    163163 
    164164    ".$i18nPeerClassName."::addSelectColumns(\$c); 
     
    167167    \$c->add(".$cultureColumnName.", \$culture); 
    168168 
    169     \$stmt = ".$this->basePeerClassname."::doSelectStmt(\$c, \$con); 
     169    \$stmt = ".$this->basePeerClassname."::doSelect(\$c, \$con); 
    170170    \$results = array(); 
    171171 
     
    174174            if ($table->getChildrenColumn()) { 
    175175              $script .= " 
    176       \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 1); 
     176      \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, \$startcol); 
    177177"; 
    178178            } else { 
     
    182182            } 
    183183            $script .= " 
    184       \$cls = Propel::import(\$omClass); 
     184      \$cls = Propel::importClass(\$omClass); 
    185185      \$obj1 = new \$cls(); 
    186186      \$obj1->hydrate(\$row); 
    187187      \$obj1->setCulture(\$culture); 
    188188"; 
    189 //            if ($i18nTable->getChildrenColumn()) { 
     189            if ($i18nTable->getChildrenColumn()) { 
    190190              $script .= " 
    191191      \$omClass = ".$i18nTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol); 
    192192"; 
    193 //            } else { 
    194 //              $script .= " 
    195 //      \$omClass = ".$i18nTablePeerBuilder->getPeerClassname()."::getOMClass(); 
    196 //"; 
    197 //            } 
     193            } else { 
     194              $script .= " 
     195      \$omClass = ".$i18nTablePeerBuilder->getPeerClassname()."::getOMClass(); 
     196"; 
     197            } 
    198198 
    199199            $script .= " 
    200       \$cls = Propel::import(\$omClass); 
     200      \$cls = Propel::importClass(\$omClass); 
    201201      \$obj2 = new \$cls(); 
    202202      \$obj2->hydrate(\$row, \$startcol); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/ClassTools.php

    r5248 r7200  
    11<?php 
    22/* 
    3  *  $Id: ClassTools.php 521 2007-01-05 13:29:36Z heltem
     3 *  $Id: ClassTools.php 942 2008-01-27 21:08:52Z hans
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2525  * 
    2626  * @author     Hans Lellelid <hans@xmpl.org> 
    27   * @version    $Revision: 521
     27  * @version    $Revision: 942
    2828  * @package    propel.engine.builder.om 
    2929  */ 
     
    105105    return $interface; 
    106106  } 
     107   
     108  /** 
     109   * Gets a list of PHP reserved words. 
     110   * 
     111   * @return array string[] 
     112   */ 
     113  public static function getPhpReservedWords() 
     114  { 
     115    return array( 
     116      'and', 'or', 'xor', 'exception', '__FILE__', '__LINE__', 
     117      'array', 'as', 'break', 'case', 'class', 'const', 'continue', 
     118      'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 
     119      'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 
     120      'eval', 'exit', 'extends', 'for', 'foreach', 'function', 'global', 
     121      'if', 'include', 'include_once', 'isset', 'list', 'new', 'print', 'require', 
     122      'require_once', 'return', 'static', 'switch', 'unset', 'use', 'var', 'while', 
     123      '__FUNCTION__', '__CLASS__', '__METHOD__', 'final', 'php_user_filter', 'interface', 
     124      'implements', 'extends', 'public', 'protected', 'private', 'abstract', 'clone', 'try', 'catch', 
     125      'throw', 'this', 'namespace' 
     126    ); 
     127  } 
    107128} 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/OMBuilder.php

    r6294 r7200  
    22 
    33/* 
    4  *  $Id: OMBuilder.php 842 2007-12-02 16:28:20Z heltem
     4 *  $Id: OMBuilder.php 942 2008-01-27 21:08:52Z hans
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    325325  public function build() 
    326326  { 
     327    $this->validateModel(); 
     328     
    327329    $script = "<" . "?php\n"; // intentional concatenation 
    328330    $this->addIncludes($script); 
     
    332334    return $script; 
    333335  } 
    334  
     336   
     337  /** 
     338   * Validates the current table to make sure that it won't  
     339   * result in generated code that will not parse. 
     340   *  
     341   * This method may emit warnings for code which may cause problems 
     342   * and will throw exceptions for errors that will definitely cause  
     343   * problems.  
     344   */ 
     345  protected function validateModel() 
     346  { 
     347    // Validation is currently only implemented in the subclasses. 
     348  } 
     349   
    335350  /** 
    336351   * Creates a $obj = new Book(); code snippet. Can be used by frameworks, for instance, to 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php

    r7119 r7200  
    22 
    33/* 
    4  *  $Id: PHP5ObjectBuilder.php 929 2008-01-18 15:17:50Z hans $ 
     4 *  $Id: PHP5ObjectBuilder.php 942 2008-01-27 21:08:52Z hans $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    5151    return $this->getBuildProperty('basePrefix') . $this->getStubObjectBuilder()->getUnprefixedClassname(); 
    5252  } 
    53  
     53   
     54  /** 
     55   * Validates the current table to make sure that it won't  
     56   * result in generated code that will not parse. 
     57   *  
     58   * This method may emit warnings for code which may cause problems 
     59   * and will throw exceptions for errors that will definitely cause  
     60   * problems.  
     61   */ 
     62  protected function validateModel() 
     63  { 
     64    parent::validateModel(); 
     65     
     66    $table = $this->getTable(); 
     67     
     68    // Check to see whether any generated foreign key names 
     69    // will conflict with column names. 
     70     
     71    $colPhpNames = array(); 
     72    $fkPhpNames = array(); 
     73     
     74    foreach($table->getColumns() as $col) { 
     75      $colPhpNames[] = $col->getPhpName(); 
     76    } 
     77 
     78    foreach($table->getForeignKeys() as $fk) { 
     79      $fkPhpNames[] = $this->getFKPhpNameAffix($fk, $plural = false); 
     80    } 
     81     
     82    $intersect = array_intersect($colPhpNames, $fkPhpNames);  
     83    if (!empty($intersect)) { 
     84      throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")"); 
     85    } 
     86     
     87    // Check foreign keys to see if there are any foreign keys that 
     88    // are also matched with an inversed referencing foreign key 
     89    // (this is currently unsupported behavior) 
     90    // see: http://propel.phpdb.org/trac/ticket/549 
     91     
     92    foreach($table->getForeignKeys() as $fk) { 
     93      if ($fk->isMatchedByInverseFK()) { 
     94        throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)" ); 
     95      } 
     96    } 
     97  } 
     98   
    5499  /** 
    55100   * Returns the appropriate formatter (from platform) for a date/time column. 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5PeerBuilder.php

    r7195 r7200  
    22 
    33/* 
    4  *  $Id: PHP5PeerBuilder.php 939 2008-01-25 14:19:29Z hans $ 
     4 *  $Id: PHP5PeerBuilder.php 942 2008-01-27 21:08:52Z hans $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3434class PHP5PeerBuilder extends PeerBuilder { 
    3535 
     36  /** 
     37   * Validates the current table to make sure that it won't  
     38   * result in generated code that will not parse. 
     39   *  
     40   * This method may emit warnings for code which may cause problems 
     41   * and will throw exceptions for errors that will definitely cause  
     42   * problems.  
     43   */ 
     44  protected function validateModel() 
     45  { 
     46    parent::validateModel(); 
     47     
     48    $table = $this->getTable(); 
     49     
     50    // Check to see if any of the column constants are PHP reserved words. 
     51    $colConstants = array(); 
     52     
     53    foreach($table->getColumns() as $col) { 
     54      $colConstants[] = $this->getColumnName($col); 
     55    } 
     56     
     57    $reservedConstants = array_map('strtoupper', ClassTools::getPhpReservedWords()); 
     58     
     59    $intersect = array_intersect($reservedConstants, $colConstants); 
     60    if (!empty($intersect)) { 
     61      throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with a PHP reserved word (" . implode(", ", $intersect) . ")");       
     62    } 
     63  } 
     64   
    3665  /** 
    3766   * Returns the name of the current class being built. 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Table.php

    r7042 r7200  
    22 
    33/* 
    4  *  $Id: Table.php 908 2008-01-10 15:48:59Z hans $ 
     4 *  $Id: Table.php 942 2008-01-27 21:08:52Z hans $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    4141 * @author     Daniel Rall <dlr@collab.net> (Torque) 
    4242 * @author     Byron Foster <byron_foster@yahoo.com> (Torque) 
    43  * @version    $Revision: 908
     43 * @version    $Revision: 942
    4444 * @package    propel.engine.database.model 
    4545 */ 
     
    790790  /** 
    791791   * Returns an Array containing all the columns in the table 
     792   * @return array Column[] 
    792793   */ 
    793794  public function getColumns() 
     
    820821  /** 
    821822   * Returns an Array containing all the validators in the table 
     823   * @return array Validator[] 
    822824   */ 
    823825  public function getValidators() 
     
    827829 
    828830  /** 
    829    * Returns an Array containing all the FKs in the table 
     831   * Returns an Array containing all the FKs in the table. 
     832   * @return array ForeignKey[] 
    830833   */ 
    831834  public function getForeignKeys()