Development

Changeset 6506

You must first sign up to be able to contribute.

Changeset 6506

Show
Ignore:
Timestamp:
12/15/07 13:03:37 (1 year ago)
Author:
dwhittle
Message:

dwhittle: merged trunk + propel changes to branch

+ standardizes initialize + loadConfiguration
+ refactored event system + unit tests
+ fixed compat10 config.php
+ fixed possible session loading twice

+ propel - coding standards + fixed tests + builder tweaks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/UPGRADE

    r6419 r6506  
    281281now extend the `sfValidatorBase` class. 
    282282 
     283`->initialize()` methods 
     284------------------------ 
     285 
     286Most symfony core classes are initialized thanks to a `->initialize()` method. As of symfony 1.1, 
     287this method is automatically called by `__construct()`, so, there is no need to call it by yourself. 
     288 
     289Configuration files loading 
     290--------------------------- 
     291 
     292Some core classes can be configured with a `.yml` file: 
     293 
     294|| '''Class'''          || '''Configuration file'''         || 
     295||                      ||                                  || 
     296|| `sfAction`           || `security.yml`                   || 
     297|| `sfAutoload`         || `autoload.yml`                   || 
     298|| `sfConfigCache`      || `config_handlers.yml`            || 
     299|| `sfContext`          || `factories.yml`                  || 
     300|| `sfController`       || `generator.yml` and `module.yml` || 
     301|| `sfDatabaseManager`  || `databases.yml`                  || 
     302|| `sfFilterChain`      || `filters.yml`                    || 
     303|| `sfI18N`             || `i18n.yml`                       || 
     304|| `sfPatternRouting`   || `routing.yml`                    || 
     305|| `sfPHPView`          || `view.yml`                       || 
     306|| `sfViewCacheManager` || `cache.yml`                      || 
     307 
     308In symfony 1.1, the loading of the configuration file for ''independant'' sub-frameworks has been 
     309moved to a `loadConfiguration()` method to ease decoupling and reuse them without needing the whole framework: 
     310 
     311  * `sfDatabaseManager` 
     312  * `sfI18N` 
     313  * `sfPatternRouting` 
     314 
     315So, for example, if you need a database manager in your batch script, you will have to change from: 
     316 
     317    [php] 
     318    $databaseManager = new sfDatabaseManager(); 
     319    $databaseManager->initialize(); 
     320 
     321to: 
     322 
     323    [php] 
     324    $databaseManager = new sfDatabaseManager(); 
     325    $databaseManager->loadConfiguration(); 
     326 
     327The `initialize()` call is not needed anymore (see the point above). 
  • branches/dwhittle/data/config/factories.yml

    r6419 r6506  
    2828    class: sfI18N 
    2929    param: 
     30      load_configuration: true 
    3031      cache: 
    3132        class: sfAPCCache 
  • branches/dwhittle/lib/command/sfCommandLogger.class.php

    r5257 r6506  
    3939  public function listenToLogEvent(sfEvent $event) 
    4040  { 
    41     $priority = $event->getParameterHolder()->remove('priority', self::INFO)
     41    $priority = isset($event['priority']) ? $event['priority'] : self::INFO
    4242 
    4343    $prefix = ''; 
     
    5050    } 
    5151 
    52     foreach ($event->getParameterHolder()->getAll() as $message) 
     52    foreach ($event->getParameters() as $message) 
    5353    { 
    5454      $this->log(sprintf('%s%s', $prefix, $message), $priority); 
  • branches/dwhittle/lib/config/sfFactoryConfigHandler.class.php

    r4966 r6506  
    148148            $cache = "    \$cache = null;\n"; 
    149149          } 
     150 
     151          $configuration = ''; 
     152          if (isset($parameters['load_configuration']) && $parameters['load_configuration']) 
     153          { 
     154            $configuration = "  \$this->factories['i18n']->loadConfiguration();\n"; 
     155          } 
    150156          $instances[] = sprintf("\n  if (sfConfig::get('sf_i18n'))\n  {\n". 
    151157                     "    \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 
    152158                     "%s". 
    153159                     "    \$this->factories['i18n'] = new \$class(\$this, \$cache);\n". 
     160                     $configuration. 
    154161                     "  }\n" 
    155162                     , $class, $cache 
  • branches/dwhittle/lib/config/sfFilterConfigHandler.class.php

    r4963 r6506  
    164164  { 
    165165    return sprintf("\nlist(\$class, \$parameters) = (array) sfConfig::get('sf_%s_filter', array('%s', %s));\n". 
    166                       "\$filter = new \$class(\$this->context, \$parameters);\n". 
    167                       "\$filterChain->register(\$filter);", 
     166                      "\$filter = new \$class(sfContext::getInstance(), \$parameters);\n". 
     167                      "\$this->register(\$filter);", 
    168168                      $category, $class, $parameters); 
    169169  } 
  • branches/dwhittle/lib/controller/sfController.class.php

    r6262 r6506  
    247247      // create a new filter chain 
    248248      $filterChain = new sfFilterChain(); 
    249  
    250       require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/filters.yml')); 
     249      $filterChain->loadConfiguration($actionInstance); 
    251250 
    252251      $this->context->getEventDispatcher()->notify(new sfEvent($this, 'controller.change_action', array('module' => $moduleName, 'action' => $actionName))); 
  • branches/dwhittle/lib/database/sfDatabaseManager.class.php

    r4963 r6506  
    5050  public function initialize() 
    5151  { 
    52     // load database configuration 
     52    $this->loadConfiguration(); 
     53  } 
     54 
     55  /** 
     56   * Loads database configuration. 
     57   */ 
     58  public function loadConfiguration() 
     59  { 
    5360    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/databases.yml')); 
    5461  } 
  • branches/dwhittle/lib/event/sfEvent.class.php

    r5047 r6506  
    1717 * @version    SVN: $Id$ 
    1818 */ 
    19 class sfEvent 
     19class sfEvent implements ArrayAccess 
    2020{ 
    2121  protected 
    22     $value           = null, 
    23     $processed       = false, 
    24     $subject         = null, 
    25     $name            = '', 
    26     $parameterHolder = null; 
     22    $value      = null, 
     23    $processed  = false, 
     24    $subject    = null, 
     25    $name       = '', 
     26    $parameters = null; 
    2727 
    2828  /** 
     
    3838    $this->name = $name; 
    3939 
    40     $this->parameterHolder = new sfParameterHolder(); 
    41     $this->parameterHolder->add($parameters); 
     40    $this->parameters = $parameters; 
    4241  } 
    4342 
     
    102101  } 
    103102 
    104   public function getParameterHolder() 
     103  public function getParameters() 
    105104  { 
    106     return $this->parameterHolder
     105    return $this->parameters
    107106  } 
    108107 
    109   public function getParameter($name, $default = null) 
     108  /** 
     109   * Returns true if the parameter exists (implements the ArrayAccess interface). 
     110   * 
     111   * @param  string  The parameter name 
     112   * 
     113   * @return Boolean true if the parameter exists, false otherwise 
     114   */ 
     115  public function offsetExists($name) 
    110116  { 
    111     return $this->parameterHolder->get($name, $default); 
     117    return isset($this->parameters[$name]); 
    112118  } 
    113119 
    114   public function hasParameter($name) 
     120  /** 
     121   * Returns a parameter value (implements the ArrayAccess interface). 
     122   * 
     123   * @param  string The parameter name 
     124   * 
     125   * @return mixed  The parameter value 
     126   */ 
     127  public function offsetGet($name) 
    115128  { 
    116     return $this->parameterHolder->has($name)
     129    return isset($this->parameters[$name]) ? $this->parameters[$name] : null
    117130  } 
    118131 
    119   public function setParameter($name, $value) 
     132  /** 
     133   * Sets a parameter (implements the ArrayAccess interface). 
     134   * 
     135   * @param string The parameter name 
     136   * @param mixed   
     137   */ 
     138  public function offsetSet($name, $value) 
    120139  { 
    121     return $this->parameterHolder->set($name, $value); 
     140    $this->parameters[$name] = $value; 
     141  } 
     142 
     143  /** 
     144   * Removes a parameter (implements the ArrayAccess interface). 
     145   * 
     146   * @param string The parameter name 
     147   */ 
     148  public function offsetUnset($name) 
     149  { 
     150    unset($this->parameters[$name]); 
    122151  } 
    123152} 
  • branches/dwhittle/lib/filter/sfFilterChain.class.php

    r4952 r6506  
    2424    $chain = array(), 
    2525    $index = -1; 
     26 
     27  /** 
     28   * Loads filters configuration for a given action instance. 
     29   * 
     30   * @param sfComponent A sfComponent instance 
     31   */ 
     32  public function loadConfiguration($actionInstance) 
     33  { 
     34    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$actionInstance->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/filters.yml')); 
     35  } 
    2636 
    2737  /** 
  • branches/dwhittle/lib/i18n/sfI18N.class.php

    r4963 r6506  
    4646    $this->cache   = $cache; 
    4747 
    48     include(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/i18n.yml')); 
    49  
    5048    $context->getEventDispatcher()->connect('user.change_culture', array($this, 'listenToChangeCultureEvent')); 
    5149    $context->getEventDispatcher()->connect('controller.change_action', array($this, 'listenToChangeActionEvent')); 
     50  } 
     51 
     52  /** 
     53   * Loads i18n configuration. 
     54   */ 
     55  public function loadConfiguration() 
     56  { 
     57    include(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/i18n.yml')); 
    5258  } 
    5359 
     
    266272  { 
    267273    // change the message format object with the new culture 
    268     $this->setCulture($event->getParameter('culture')); 
     274    $this->setCulture($event['culture']); 
    269275  } 
    270276 
     
    278284  { 
    279285    // change message source directory to our module 
    280     $this->setMessageSource(sfLoader::getI18NDirs($event->getParameter('module'))); 
     286    $this->setMessageSource(sfLoader::getI18NDirs($event['module'])); 
    281287  } 
    282288} 
  • branches/dwhittle/lib/log/sfLogger.class.php

    r5245 r6506  
    213213   * 
    214214   * @param sfEvent An sfEvent instance 
    215    * 
    216215   */ 
    217216  public function listenToLogEvent(sfEvent $event) 
    218217  { 
    219     $priority = $event->getParameterHolder()->remove('priority', self::INFO)
     218    $priority = isset($event['priority']) ? $event['priority'] : self::INFO
    220219    $subject  = $event->getSubject(); 
    221220    $subject  = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main'); 
    222     foreach ($event->getParameterHolder()->getAll() as $message) 
     221    foreach ($event->getParameters() as $message) 
    223222    { 
    224223      $this->log(sprintf('{%s} %s', $subject, $message), $priority); 
  • branches/dwhittle/lib/plugin/sfSymfonyPluginManager.class.php

    r5257 r6506  
    110110  public function ListenToPluginPostInstall($event) 
    111111  { 
    112     $this->installWebContent($event->getParameter('plugin')); 
     112    $this->installWebContent($event['plugin']); 
    113113  } 
    114114 
     
    120120  public function ListenToPluginPostUninstall($event) 
    121121  { 
    122     $this->uninstallWebContent($event->getParameter('plugin')); 
     122    $this->uninstallWebContent($event['plugin']); 
    123123  } 
    124124 
  • branches/dwhittle/lib/plugins/sfCompat10Plugin/config/config.php

    r5386 r6506  
    11<?php 
    22 
    3 class sfCompatAutoload extends sfSimpleAutoload 
     3if (!class_exists('sfCompatAutoload', false)) 
    44{ 
     5  class sfCompatAutoload extends sfSimpleAutoload 
     6  { 
     7  } 
     8 
     9  if (sfConfig::get('sf_compat_10')) 
     10  { 
     11    // autoload classes 
     12    $autoload = sfCompatAutoload::getInstance(sfConfig::get('sf_app_cache_dir').'/sf_compat_autoloader.txt'); 
     13    $autoload->addDirectory(dirname(__FILE__).'/../lib'); 
     14    $autoload->register(); 
     15 
     16    // register config handler for validate/*.yml files 
     17    sfConfigCache::getInstance()->registerConfigHandler('modules/*/validate/*.yml', 'sfValidatorConfigHandler'); 
     18 
     19    // register the validation execution filter 
     20    sfConfig::set('sf_execution_filter', array('sfValidationExecutionFilter', array())); 
     21  } 
    522} 
    6  
    7 if (sfConfig::get('sf_compat_10')) 
    8 { 
    9   // autoload classes 
    10   $autoload = sfCompatAutoload::getInstance(sfConfig::get('sf_app_cache_dir').'/sf_compat_autoloader.txt'); 
    11   $autoload->addDirectory(dirname(__FILE__).'/../lib'); 
    12   $autoload->register(); 
    13  
    14   // register config handler for validate/*.yml files 
    15   sfConfigCache::getInstance()->registerConfigHandler('modules/*/validate/*.yml', 'sfValidatorConfigHandler'); 
    16  
    17   // register the validation execution filter 
    18   sfConfig::set('sf_execution_filter', array('sfValidationExecutionFilter', array())); 
    19 } 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropel.class.php

    r5869 r6506  
    5555  static public function listenToChangeCultureEvent(sfEvent $event) 
    5656  { 
    57     self::setDefaultCulture($event->getParameter('culture')); 
     57    self::setDefaultCulture($event['culture']); 
    5858  } 
    5959} 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml

    r5248 r6506  
    476476      xmlConfFile="${propel.conf.dir}/${propel.runtime.conf.file}" 
    477477      outputDirectory="${propel.phpconf.dir}" 
    478       outputFile="${propel.runtime.phpconf.file}"> 
     478      outputFile="${propel.runtime.phpconf.file}" 
     479      outputClassmapFile="${propel.runtime.phpconf-classmap.file}"> 
    479480      <schemafileset dir="${propel.schema.dir}" 
    480481        includes="${propel.schema.sql.includes}" 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/DataModelBuilder.php

    r6294 r6506  
    22 
    33/* 
    4  *  $Id: DataModelBuilder.php 844 2007-12-02 17:57:36Z hans
     4 *  $Id: DataModelBuilder.php 857 2007-12-13 14:59:59Z heltem
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    278278    return $result; 
    279279  } 
    280    
     280 
    281281  /** 
    282282  * A Name to use for the serials (dependant sequence in PostgreSQL) 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5NestedSetPeerBuilder.php

    r6471 r6506  
    22 
    33/* 
    4  *  $Id: PHP5NestedSetPeerBuilder.php 854 2007-12-11 13:09:13Z heltem $ 
     4 *  $Id: PHP5NestedSetPeerBuilder.php 865 2007-12-13 23:04:49Z heltem $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    171171 
    172172    $this->addShiftRParent($script); 
    173     $this->addupdateDBNode($script); 
     173    $this->addUpdateLoadedNode($script); 
     174    $this->addUpdateDBNode($script); 
    174175 
    175176    $this->addShiftRLValues($script); 
     
    311312    self::shiftRLValues(\$child->getLeftValue(), 2, \$con, \$sidv); 
    312313 
    313     // Update \$parent nodes properties recursively 
    314     self::shiftRParent(\$parent, 2, \$con); 
     314    // Update all loaded nodes 
     315    self::updateLoadedNode(\$parent, 2, \$con); 
    315316  } 
    316317"; 
     
    348349    self::shiftRLValues(\$child->getLeftValue(), 2, \$con, \$sidv); 
    349350 
    350     // Update \$parent nodes properties recursively 
    351     self::shiftRParent(\$parent, 2, \$con); 
     351    // Update all loaded nodes 
     352    self::updateLoadedNode(\$parent, 2, \$con); 
    352353  } 
    353354"; 
     
    385386    self::shiftRLValues(\$node->getLeftValue(), 2, \$con, \$sidv); 
    386387 
    387     // Update \$parent nodes properties recursively 
    388     self::shiftRParent(\$sibling->retrieveParent(), 2, \$con); 
     388    // Update all loaded nodes 
     389    self::updateLoadedNode(\$sibling->retrieveParent(), 2, \$con); 
    389390  } 
    390391"; 
     
    422423    self::shiftRLValues(\$node->getLeftValue(), 2, \$con, \$sidv); 
    423424 
    424     // Update \$parent nodes properties recursively 
    425     self::shiftRParent(\$sibling->retrieveParent(), 2, \$con); 
     425    // Update all loaded nodes 
     426    self::updateLoadedNode(\$sibling->retrieveParent(), 2, \$con); 
    426427  } 
    427428"; 
     
    464465    \$node->save(\$con); 
    465466 
    466     // Update \$parent nodes properties recursively 
    467     self::shiftRParent(\$previous_parent, 2, \$con); 
     467    // Update all loaded nodes 
     468    self::updateLoadedNode(\$previous_parent, 2, \$con); 
    468469  } 
    469470"; 
     
    13831384  } 
    13841385 
     1386  /** 
     1387   * TODO : Fix this broken in-memory nodes updater 
     1388   * Don't trust it 
     1389   */ 
    13851390  protected function addShiftRParent(&$script) 
    13861391  { 
     
    14081413  } 
    14091414 
    1410   protected function addupdateDBNode(&$script) 
    1411   { 
    1412     $objectClassname = $this->getStubObjectBuilder()->getClassname(); 
    1413     $script .= " 
    1414   /** 
    1415    * Move \$node and its children to location \$dest and updates rest of tree 
     1415  protected function addUpdateLoadedNode(&$script) 
     1416  { 
     1417    $objectClassname = $this->getStubObjectBuilder()->getClassname(); 
     1418    $peerClassname = $this->getStubPeerBuilder()->getClassname(); 
     1419    $table = $this->getTable(); 
     1420 
     1421    $script .= " 
     1422  /** 
     1423   * Reload all already loaded nodes to sync them with updated db 
     1424   * 
     1425   * @param      $objectClassname \$node  Propel object for parent node 
     1426   * @param      int \$delta  Value to be shifted by, can be negative 
     1427   * @param      PropelPDO \$con    Connection to use. 
     1428   */ 
     1429  protected static function updateLoadedNode(NodeObject \$node, \$delta, PropelPDO \$con = null) 
     1430  { 
     1431    if (Propel::isInstancePoolingEnabled()) 
     1432    { 
     1433      \$keys = array(); 
     1434      foreach(self::\$instances as \$obj) 
     1435      { 
     1436        \$keys[] = \$obj->getPrimaryKey(); 
     1437      } 
     1438 
     1439      if(!empty(\$keys)) 
     1440      { 
     1441        // We don't need to alter the object instance pool; we're just modifying this instance 
     1442        // already in the pool. 
     1443 
     1444        \$criteria = new Criteria(self::DATABASE_NAME); 
     1445"; 
     1446      foreach ($table->getColumns() as $col) { 
     1447        if ($col->isPrimaryKey()) { 
     1448          $script .= " 
     1449        \$criteria->add(".$this->getColumnConstant($col).", \$keys, Criteria::IN); 
     1450"; 
     1451          break; 
     1452        } /* if col is prim key */ 
     1453      } /* foreach */ 
     1454      $script .= " 
     1455        $peerClassname::populateObjects($peerClassname::doSelectStmt(\$criteria, \$con)); 
     1456      } 
     1457    } 
     1458    else 
     1459    { 
     1460      // FIX: Do a refresh for all in-memory nodes with a real tree traversal 
     1461      self::shiftRParent(\$node, \$delta, \$con); 
     1462    } 
     1463  } 
     1464"; 
     1465  } 
     1466 
     1467  protected function addUpdateDBNode(&$script) 
     1468  { 
     1469    $objectClassname = $this->getStubObjectBuilder()->getClassname(); 
     1470    $script .= " 
     1471  /** 
     1472   * Move \$node and its children to location \$destLeft and updates rest of tree 
    14161473   * 
    14171474   * @param      $objectClassname \$node Propel object for node to update 
     1475   * @param      int  \$destLeft Destination left value 
    14181476   * @param      PropelPDO \$con    Connection to use. 
    1419    * @param      int   Destination left value 
    14201477   */ 
    14211478  protected static function updateDBNode(NodeObject \$node, \$destLeft, PropelPDO \$con = null) 
     
    15381595    // Shift left column values 
    15391596    \$whereCriteria = new Criteria(); 
    1540     \$criterion = \$whereCriteria->getNewCriterion(\$leftUpdateCol, \$first, Criteria::GREATER_EQUAL); 
    1541     \$criterion->addAnd(\$whereCriteria->getNewCriterion(\$leftUpdateCol, \$last, Criteria::LESS_EQUAL)); 
     1597    \$criterion = \$whereCriteria->getNewCriterion(self::LEFT_COL, \$first, Criteria::GREATER_EQUAL); 
     1598    \$criterion->addAnd(\$whereCriteria->getNewCriterion(self::LEFT_COL, \$last, Criteria::LESS_EQUAL)); 
    15421599    if (self::SCOPE_COL) { 
    15431600      \$criterion->addAnd(\$whereCriteria->getNewCriterion(self::SCOPE_COL, \$scopeId, Criteria::EQUAL)); 
     
    15551612    // Shift right column values 
    15561613    \$whereCriteria = new Criteria(); 
    1557     \$criterion = \$whereCriteria->getNewCriterion(\$rightUpdateCol, \$first, Criteria::GREATER_EQUAL); 
    1558     \$criterion->addAnd(\$whereCriteria->getNewCriterion(\$rightUpdateCol, \$last, Criteria::LESS_EQUAL)); 
     1614    \$criterion = \$whereCriteria->getNewCriterion(self::RIGHT_COL, \$first, Criteria::GREATER_EQUAL); 
     1615    \$criterion->addAnd(\$whereCriteria->getNewCriterion(self::RIGHT_COL, \$last, Criteria::LESS_EQUAL)); 
    15591616    if (self::SCOPE_COL) { 
    15601617      \$criterion->addAnd(\$whereCriteria->getNewCriterion(self::SCOPE_COL, \$scopeId, Criteria::EQUAL)); 
     
    15641621    \$valuesCriteria = new Criteria(); 
    15651622    \$valuesCriteria->add( 
    1566       self::LEFT_COL, 
     1623      self::RIGHT_COL, 
    15671624      array('raw' => \$rightUpdateCol . ' + ?', 'value' => \$delta), 
    15681625      Criteria::CUSTOM_EQUAL); 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php

    r6309 r6506  
    22 
    33/* 
    4  *  $Id: PHP5ObjectBuilder.php 848 2007-12-03 20:25:53Z hans
     4 *  $Id: PHP5ObjectBuilder.php 857 2007-12-13 14:59:59Z heltem
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    22262226  /** 
    22272227   * Clears out the $collName collection (array). 
    2228    *  
    2229    * This does not modify the database; however, it will remove any associated objects, causing  
     2228   * 
     2229   * This does not modify the database; however, it will remove any associated objects, causing 
    22302230   * them to be refetched by subsequent calls to accessor method. 
    22312231   * 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/transform/XmlToData.php

    r5248 r6506  
    22 
    33/* 
    4  *  $Id: XmlToData.php 521 2007-01-05 13:29:36Z heltem
     4 *  $Id: XmlToData.php 861 2007-12-13 17:42:50Z gamr
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3232 * @author     Martin Poeschl <mpoeschl@marmot.at> (Torque) 
    3333 * @author     Fedor Karpelevitch <fedor.karpelevitch@home.com> (Torque) 
    34  * @version    $Revision: 521 $ 
     34 * @version    $Revision: 861 $ 
    3535 * @package    propel.engine.database.transform 
    3636 */ 
     
    4141 
    4242  private $encoding; 
     43  private $callback; 
    4344 
    4445  public $parser; 
     
    6364   * 
    6465   */ 
    65   public function parseFile($xmlFile
     66  public function parseFile($xmlFile,$callback=null
    6667  { 
     68    if ( $callback ) { 
     69      $this->callback = $callback; 
     70    } 
    6771    try { 
    6872 
     
    113117          $this->columnValues[] = new ColumnValue($col, iconv('utf-8',$this->encoding, $value)); 
    114118        } 
    115         $this->data[] = new DataRow($table, $this->columnValues); 
     119        $data = new DataRow($table, $this->columnValues); 
     120        if ( $this->callback ) { 
     121          call_user_func($this->callback,$data); 
     122          $data = null; 
     123        } else { 
     124          $this->data[] = $data; 
     125        } 
    116126      } 
    117127    } catch (Exception $e) { 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/platform/Platform.php

    r6294 r6506  
    11<?php 
    22/* 
    3  *  $Id: Platform.php 844 2007-12-02 17:57:36Z hans
     3 *  $Id: Platform.php 857 2007-12-13 14:59:59Z heltem
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2525 * @author     Hans Lellelid <hans@xmpl.org> (Propel) 
    2626 * @author     Martin Poeschl <mpoeschl@marmot.at> (Torque) 
    27  * @version    $Revision: 844
     27 * @version    $Revision: 857
    2828 * @package    propel.engine.platform 
    2929 */ 
     
    3939   */ 
    4040  const SEQUENCE = "sequence"; 
    41    
     41 
    4242  /** 
    4343   * Constant for serial id method (postgresql). 
    4444   */ 
    4545  const SERIAL = "serial"; 
    46    
     46 
    4747  /** 
    4848   * Sets a database connection to use (for quoting, etc.). 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/phing/PropelConvertConfTask.php

    r6248 r6506  
    22 
    33/* 
    4  *  $Id: PropelConvertConfTask.php 832 2007-11-30 11:41:52Z hans $ 
     4 *  $Id: PropelConvertConfTask.php 866 2007-12-14 19:13:24Z hans $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    4040 
    4141  /** 
    42    * @var        PhingFile This is the file where the converted conf array dump will be placed. 
     42   * @var        string This is the file where the converted conf array dump will be placed. 
    4343   */ 
    4444  private $outputFile; 
     45 
     46  /** 
     47   * @var        string This is the file where the classmap manifest converted conf array dump will be placed. 
     48   */ 
     49  private $outputClassmapFile; 
    4550 
    4651  /** 
     
    6671 
    6772  /** 
     73   * [REQUIRED] Set the output filename for the autoload classmap. 
     74   * The directory is specified using AbstractPropelDataModelTask#setOutputDirectory(). 
     75   * @param      string $outputFile 
     76   * @see        AbstractPropelDataModelTask#setOutputDirectory() 
     77   */ 
     78  public function setOutputClassmapFile($outputFile) 
     79  { 
     80    // this is a string, not a file 
     81    $this->outputClassmapFile = $outputFile; 
     82  } 
     83 
     84  /** 
    6885   * The main method does the work of the task. 
    6986   */ 
     
    7895    if (!$this->outputFile) { 
    7996      throw new BuildException("No outputFile specified.", $this->getLocation()); 
     97    } 
     98 
     99    if (!$this->outputClassmapFile) { 
     100      // We'll create a default one for BC 
     101      $this->outputClassmapFile = 'classmap-' . $this->outputFile; 
    80102    } 
    81103 
     
    87109 
    88110    $phpconf = self::simpleXmlToArray($xml); 
    89  
     111    $phpconfClassmap = array(); 
     112     
    90113    // $this->log(var_export($phpconf,true)); 
    91114 
     
    99122 
    100123        $classMap = array(); 
    101  
     124         
    102125        // $this->log("Processing class mappings in database: " . $database->getName()); 
    103126 
    104     //print the tables 
     127       //print the tables 
    105128        foreach ($database->getTables() as $table) { 
    106129 
     
    162185        } 
    163186 
    164         $phpconf['propel']['datasources'][$database->getName()]['classes'] = $classMap; 
    165       } 
    166     } 
    167  
    168 //    $phpconf['propel']['classes'] = $classMap; 
     187        $phpconfClassmap['propel']['datasources'][$database->getName()]['classes'] = $classMap; 
     188      } 
     189    } 
     190 
     191   //   $phpconf['propel']['classes'] = $classMap; 
    169192 
    170193    $phpconf['propel']['generator_version'] = DataModelBuilder::getBuildProperty('version'); 
     
    177200    $output .= "// This file generated by Propel " . $phpconf['propel']['generator_version'] . " convert-props target".(DataModelBuilder::getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; 
    178201    $output .= "// from XML runtime conf file " . $this->xmlConfFile->getPath() . "\n"; 
    179     $output .= "return "; 
    180     $output .= var_export($phpconf, true); 
    181     $output .= ";"; 
    182  
    183     $this->log("Creating PHP runtime conf file: " . $outfile->getPath()); 
    184  
    185     if (!file_put_contents($outfile->getAbsolutePath(), $output)) { 
    186       throw new BuildException("Error creating output file: " . $outfile->getAbsolutePath(), $this->getLocation()); 
    187     } 
     202    $output .= "return array_merge_recursive("; 
     203    $output .= var_export($phpconf, true); 
     204    $output .= ", include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '".$this->outputClassmapFile."'));"; 
     205 
     206    $this->log("Creating PHP runtime conf file: " . $outfile->getPath()); 
     207    if (!file_put_contents($outfile->getAbsolutePath(), $output)) { 
     208      throw new BuildException("Error creating output file: " . $outfile->getAbsolutePath(), $this->getLocation()); 
     209    } 
     210 
     211    $outfile = new PhingFile($this->outputDirectory, $this->outputClassmapFile); 
     212    $output = '<' . '?' . "php\n"; 
     213    $output .= "// This file generated by Propel " . $phpconf['propel']['generator_version'] . " convert-props target".(DataModelBuilder::getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; 
     214    $output .= "return "; 
     215    $output .= var_export($phpconfClassmap, true); 
     216    $output .= ";"; 
     217    $this->log("Creating PHP classmap runtime file: " . $outfile->getPath()); 
     218    if (!file_put_contents($outfile->getAbsolutePath(), $output)) { 
     219      throw new BuildException("Error creating output file: " . $outfile->getAbsolutePath(), $this->getLocation()); 
     220    } 
     221       
    188222 
    189223  } // main() 
     
    230264      } 
    231265 
    232       // if the $k is already in our children list, we need to transform 
    233       // it into an array, else we add it as a value 
    234       if ( !in_array( $k, array_keys($ar) ) ) { 
    235         $ar[$k] = $child; 
    236       } else { 
    237         // if the $ar[$k] element is not already an array, then we need to make it one 
    238         if ( !is_array( $ar[$k] ) ) { $ar[$k] = array( $ar[$k] ); } 
    239         $ar[$k][] = $child; 
    240      
     266      // if the $k is already in our children list, we need to transform 
     267      // it into an array, else we add it as a value 
     268      if ( !in_array( $k, array_keys($ar) ) ) { 
     269        $ar[$k] = $child; 
     270      } else { 
     271        // if the $ar[$k] element is not already an array, then we need to make it one 
     272        if ( !is_array( $ar[$k] ) ) { $ar[$k] = array( $ar[$k] ); } 
     273        $ar[$k][] = $child; 
     274