Development

Changeset 6882

You must first sign up to be able to contribute.

Changeset 6882

Show
Ignore:
Timestamp:
01/02/08 09:27:53 (10 months ago)
Author:
fabien
Message:

refactored crud generator to use the new form framework

  • merged propel:generate-crud propel:init-crud to a single propel:generate-crud task
  • added new options to the task:
    • --generate-in-cache
    • --non-atomic-actions
    • --non-verbose-templates
    • --with-show
  • propel:generate-crud is fully functional tested (we have now 7000 tests, yeah...)
  • fixed command line tests
  • oh, and happy new year to all people following the timeline and reading my boring commit comments ;-)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/generator/sfAdminGenerator.class.php

    r5102 r6882  
    709709  } 
    710710 
     711  public function getFormObject() 
     712  { 
     713    $class = $this->getClassName().'Form'; 
     714 
     715    return new $class(); 
     716  } 
     717 
     718  public function getHiddenFields() 
     719  { 
     720    $form = $this->getFormObject(); 
     721    $hiddenFields = array(); 
     722    foreach ($form->getWidgetSchema()->getPositions() as $name) 
     723    { 
     724      if ($form[$name]->isHidden()) 
     725      { 
     726        $hiddenFields[] = $name; 
     727      } 
     728    } 
     729 
     730    return $hiddenFields; 
     731  } 
     732 
     733  public function getHiddenFieldsAsString() 
     734  { 
     735    $hiddenFields = ''; 
     736    foreach ($this->getHiddenFields() as $name) 
     737    { 
     738      $hiddenFields .= '        [?php echo $form[\''.$name.'\'] ?]'."\n"; 
     739    } 
     740 
     741    return "\n".$hiddenFields; 
     742  } 
     743 
     744  public function getLastNonHiddenField() 
     745  { 
     746    $form = $this->getFormObject(); 
     747    $positions = $form->getWidgetSchema()->getPositions(); 
     748    $last = count($positions) - 1; 
     749    for ($i = count($positions) - 1; $i >= 0; $i--) 
     750    { 
     751      if ($form[$positions[$i]]->isHidden()) 
     752      { 
     753        $last = $i - 1; 
     754      } 
     755      else 
     756      { 
     757        break; 
     758      } 
     759    } 
     760 
     761    return $last; 
     762  } 
     763 
    711764  /** 
    712765   * Escapes a string. 
  • branches/1.1/lib/generator/sfCrudGenerator.class.php

    r5098 r6882  
    9696   * @return string The PHP code 
    9797   */ 
    98   public function getRetrieveByPkParamsForAction($indent
     98  public function getRetrieveByPkParamsForAction($indent, $callee = '$this->getRequestParameter'
    9999  { 
    100100    $params = array(); 
    101101    foreach ($this->getPrimaryKey() as $pk) 
    102102    { 
    103       $params[] = "\$this->getRequestParameter('".sfInflector::underscore($pk->getPhpName())."')"; 
     103      $params[] = "$callee('".sfInflector::underscore($pk->getPhpName())."')"; 
     104    } 
     105 
     106    return implode(",\n".str_repeat(' ', max(0, $indent - strlen($this->singularName.$this->className))), $params); 
     107  } 
     108 
     109  /** 
     110   * Returns PHP code for primary keys parameters. 
     111   * 
     112   * @param integer The indentation value 
     113   * 
     114   * @return string The PHP code 
     115   */ 
     116  public function getRetrieveByPkParamsForEdit($indent, $prefix) 
     117  { 
     118    $params = array(); 
     119    foreach ($this->getPrimaryKey() as $pk) 
     120    { 
     121      $name = sfInflector::underscore($pk->getPhpName()); 
     122//      $params[] = sprintf("\$request->getParameter('%s', \$request->getParameter('%s'))", sprintf('%s[%s]', $prefix, $name), $name); 
     123      $params[] = sprintf("\$request->getParameter('%s')", $name); 
    104124    } 
    105125 
  • branches/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelCrud/default/skeleton/config/generator.yml

    r500 r6882  
    44    model_class:      ##MODEL_CLASS## 
    55    theme:            default 
     6 
     7##CONFIG## 
  • branches/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelCrud/default/template/actions/actions.class.php

    r4334 r6882  
    22 
    33/** 
    4  * <?php echo $this->getGeneratedModuleName() ?> actions. 
     4 * <?php echo $this->getModuleName() ?> actions. 
    55 * 
    66 * @package    ##PROJECT_NAME## 
    7  * @subpackage <?php echo $this->getGeneratedModuleName() ?> 
     7 * @subpackage <?php echo $this->getModuleName() ?> 
    88 
    99 * @author     ##AUTHOR_NAME## 
     
    1414  public function executeIndex() 
    1515  { 
    16     return $this->forward('<?php echo $this->getModuleName() ?>', 'list'); 
     16    $this-><?php echo $this->getSingularName() ?>List = <?php echo $this->getClassName() ?>Peer::doSelect(new Criteria()); 
    1717  } 
    1818 
    19   public function executeList() 
     19<?php if (isset($this->params['with_show']) && $this->params['with_show']): ?> 
     20  public function executeShow($request) 
    2021  { 
    21     $this-><?php echo $this->getPluralName() ?> = <?php echo $this->getClassName() ?>Peer::doSelect(new Criteria()); 
    22   } 
    23  
    24   public function executeShow() 
    25   { 
    26     $this-><?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49) ?>); 
     22    $this-><?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49, '$request->getParameter') ?>); 
    2723    $this->forward404Unless($this-><?php echo $this->getSingularName() ?>); 
    2824  } 
    2925 
     26<?php endif; ?> 
     27<?php if (isset($this->params['non_atomic_actions']) && $this->params['non_atomic_actions']): ?> 
     28  public function executeEdit($request) 
     29  { 
     30    $this->form = new <?php echo $this->getClassName() ?>Form(<?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForEdit(49, $this->getSingularName()) ?>)); 
     31 
     32    if ($request->isMethod('post')) 
     33    { 
     34      $this->form->bind($request->getParameter('<?php echo $this->getSingularName() ?>')); 
     35      if ($this->form->isValid()) 
     36      { 
     37        $<?php echo $this->getSingularName() ?> = $this->form->save(); 
     38 
     39        $this->redirect('<?php echo $this->getModuleName() ?>/edit?<?php echo $this->getPrimaryKeyUrlParams() ?>); 
     40      } 
     41    } 
     42  } 
     43<?php else: ?> 
    3044  public function executeCreate() 
    3145  { 
    32     $this-><?php echo $this->getSingularName() ?> = new <?php echo $this->getClassName() ?>(); 
     46    $this->form = new <?php echo $this->getClassName() ?>Form(); 
    3347 
    3448    $this->setTemplate('edit'); 
    3549  } 
    3650 
    37   public function executeEdit(
     51  public function executeEdit($request
    3852  { 
    39     $this-><?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49) ?>); 
    40     $this->forward404Unless($this-><?php echo $this->getSingularName() ?>); 
     53    $this->form = new <?php echo $this->getClassName() ?>Form(<?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49, '$request->getParameter') ?>)); 
    4154  } 
    4255 
    43   public function executeUpdate(
     56  public function executeUpdate($request
    4457  { 
    45     if (<?php echo $this->getTestPksForGetOrCreate(false) ?>) 
     58    $this->forward404Unless($request->isMethod('post')); 
     59 
     60    $this->form = new <?php echo $this->getClassName() ?>Form(<?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49, '$request->getParameter') ?>)); 
     61 
     62    $this->form->bind($this->getRequestParameter('<?php echo $this->getSingularName() ?>')); 
     63    if ($this->form->isValid()) 
    4664    { 
    47       $<?php echo $this->getSingularName() ?> = new <?php echo $this->getClassName() ?>(); 
    48     } 
    49     else 
    50     { 
    51       $<?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(45) ?>); 
    52       $this->forward404Unless($<?php echo $this->getSingularName() ?>); 
     65      $<?php echo $this->getSingularName() ?> = $this->form->save(); 
     66 
     67      $this->redirect('<?php echo $this->getModuleName() ?>/edit?<?php echo $this->getPrimaryKeyUrlParams() ?>); 
    5368    } 
    5469 
    55 <?php foreach ($this->getTableMap()->getColumns() as $name => $column): $type = $column->getCreoleType(); ?> 
    56 <?php if ($name == 'CREATED_AT' || $name == 'UPDATED_AT') continue ?> 
    57 <?php $name = sfInflector::underscore($column->getPhpName()) ?> 
    58 <?php if ($type == CreoleTypes::DATE || $type == CreoleTypes::TIMESTAMP): ?> 
    59     if ($this->getRequestParameter('<?php echo $name ?>')) 
    60     { 
    61       list($d, $m, $y) = $this->getContext()->getI18N()->getDateForCulture($this->getRequestParameter('<?php echo $name ?>'), $this->getUser()->getCulture()); 
    62       $<?php echo $this->getSingularName() ?>->set<?php echo $column->getPhpName() ?>("$y-$m-$d"); 
    63     } 
    64 <?php elseif ($type == CreoleTypes::BOOLEAN): ?> 
    65     $<?php echo $this->getSingularName() ?>->set<?php echo $column->getPhpName() ?>($this->getRequestParameter('<?php echo $name ?>', 0)); 
    66 <?php elseif ($column->isForeignKey()): ?> 
    67     $<?php echo $this->getSingularName() ?>->set<?php echo $column->getPhpName() ?>($this->getRequestParameter('<?php echo $name ?>') ? $this->getRequestParameter('<?php echo $name ?>') : null); 
    68 <?php else: ?> 
    69     $<?php echo $this->getSingularName() ?>->set<?php echo $column->getPhpName() ?>($this->getRequestParameter('<?php echo $name ?>')); 
     70    $this->setTemplate('edit'); 
     71  } 
    7072<?php endif; ?> 
    71 <?php endforeach; ?> 
    7273 
    73     $<?php echo $this->getSingularName() ?>->save(); 
    74  
    75     return $this->redirect('<?php echo $this->getModuleName() ?>/show?<?php echo $this->getPrimaryKeyUrlParams() ?>); 
    76 <?php //' ?> 
    77   } 
    78  
    79   public function executeDelete() 
     74  public function executeDelete($request) 
    8075  { 
    81     $<?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43) ?>); 
    82  
    83     $this->forward404Unless($<?php echo $this->getSingularName() ?>); 
     76    $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>)); 
    8477 
    8578    $<?php echo $this->getSingularName() ?>->delete(); 
    8679 
    87     return $this->redirect('<?php echo $this->getModuleName() ?>/list'); 
     80    $this->redirect('<?php echo $this->getModuleName() ?>/index'); 
    8881  } 
    8982} 
  • branches/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelCrud/default/template/templates/editSuccess.php

    r2726 r6882  
    1 [?php use_helper('Object') ?] 
     1<?php $form = $this->getFormObject() ?> 
     2[?php $<?php echo $this->getSingularName() ?> = $form->getObject() ?] 
     3<h1>[?php echo $<?php echo $this->getSingularName() ?>->isNew() ? 'New' : 'Edit' ?] <?php echo sfInflector::humanize($this->getModuleName()) ?></h1> 
    24 
    3 [?php echo form_tag('<?php echo $this->getModuleName() ?>/update') ?] 
     5<form action="[?php echo url_for('<?php echo $this->getModuleName() ?>/<?php echo isset($this->params['non_atomic_actions']) && $this->params['non_atomic_actions'] ? 'edit' : 'update' ?>'.(!$<?php echo $this->getSingularName() ?>->isNew() ? '?<?php echo $this->getPrimaryKeyUrlParams() ?> : '')) ?]" method="post" [?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?]> 
     6  <table> 
     7    <tfoot> 
     8      <tr> 
     9        <td colspan="2"> 
     10          &nbsp;<a href="[?php echo url_for('<?php echo $this->getModuleName() ?>/index') ?]">Cancel</a> 
     11          [?php if (!$<?php echo $this->getSingularName() ?>->isNew()): ?] 
     12            &nbsp;[?php echo link_to('Delete', '<?php echo $this->getModuleName() ?>/delete?<?php echo $this->getPrimaryKeyUrlParams() ?>, array('post' => true, 'confirm' => 'Are you sure?')) ?] 
     13          [?php endif; ?] 
     14          <input type="submit" value="Save" /> 
     15        </td> 
     16      </tr> 
     17    </tfoot> 
     18    <tbody> 
     19<?php if (isset($this->params['non_verbose_templates']) && $this->params['non_verbose_templates']): ?> 
     20      [?php echo $this->getAttributeHolder()->isEscaped() ? $form->render(ESC_RAW) : $form ?] 
     21<?php else: ?> 
    422 
    5 <?php foreach ($this->getPrimaryKey() as $pk): ?> 
    6 [?php echo object_input_hidden_tag($<?php echo $this->getSingularName() ?>, 'get<?php echo $pk->getPhpName() ?>') ?] 
     23<?php foreach ($form->getWidgetSchema()->getPositions() as $i => $name): ?> 
     24<?php if ($form[$name]->isHidden()) continue ?> 
     25      <tr> 
     26        <th><?php echo $form[$name]->renderLabel() ?></th> 
     27        <td> 
     28          [?php echo $form['<?php echo $name ?>']->renderError() ?] 
     29          [?php echo $form['<?php echo $name ?>'] ?] 
     30<?php $i == $this->getLastNonHiddenField() and print $this->getHiddenFieldsAsString() ?> 
     31        </td> 
     32      </tr> 
    733<?php endforeach; ?> 
    8  
    9 <table> 
    10 <tbody> 
    11 <?php foreach ($this->getTableMap()->getColumns() as $name => $column): ?> 
    12 <?php if ($column->isPrimaryKey()) continue ?> 
    13 <?php if ($name == 'CREATED_AT' || $name == 'UPDATED_AT') continue ?> 
    14 <tr> 
    15   <th><?php echo sfInflector::humanize(sfInflector::underscore($column->getPhpName())) ?><?php if ($column->isNotNull()): ?>*<?php endif; ?>:</th> 
    16   <td>[?php echo <?php echo $this->getCrudColumnEditTag($column) ?> ?]</td> 
    17 </tr> 
    18 <?php endforeach; ?> 
    19 </tbody> 
    20 </table> 
    21 <hr /> 
    22 [?php echo submit_tag('save') ?] 
    23 [?php if (<?php echo $this->getPrimaryKeyIsSet() ?>): ?] 
    24   &nbsp;[?php echo link_to('delete', '<?php echo $this->getModuleName() ?>/delete?<?php echo $this->getPrimaryKeyUrlParams() ?>, 'post=true&confirm=Are you sure?') ?] 
    25   &nbsp;[?php echo link_to('cancel', '<?php echo $this->getModuleName() ?>/show?<?php echo $this->getPrimaryKeyUrlParams() ?>) ?] 
    26 [?php else: ?] 
    27   &nbsp;[?php echo link_to('cancel', '<?php echo $this->getModuleName() ?>/list') ?] 
    28 [?php endif; ?] 
     34<?php endif; ?> 
     35    </tbody> 
     36  </table> 
    2937</form> 
  • branches/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelCrud/default/template/templates/showSuccess.php

    r1228 r6882  
    11<table> 
    2 <tbody> 
     2  <tbody> 
    33<?php foreach ($this->getTableMap()->getColumns() as $column): ?> 
    4 <tr> 
    5 <th><?php echo sfInflector::humanize(sfInflector::underscore($column->getPhpName())) ?>: </th> 
    6 <td>[?= $<?php echo $this->getSingularName() ?>->get<?php echo $column->getPhpName() ?>() ?]</td> 
    7 </tr> 
     4    <tr> 
     5      <th><?php echo sfInflector::humanize(sfInflector::underscore($column->getPhpName())) ?>:</th> 
     6      <td>[?= $<?php echo $this->getSingularName() ?>->get<?php echo $column->getPhpName() ?>() ?]</td> 
     7    </tr> 
    88<?php endforeach; ?> 
    9 </tbody> 
     9  </tbody> 
    1010</table> 
     11 
    1112<hr /> 
    12 [?php echo link_to('edit', '<?php echo $this->getModuleName() ?>/edit?<?php echo $this->getPrimaryKeyUrlParams() ?>) ?] 
    13 &nbsp;[?php echo link_to('list', '<?php echo $this->getModuleName() ?>/list') ?] 
     13 
     14<a href="[?php echo url_for('<?php echo $this->getModuleName() ?>/edit?<?php echo $this->getPrimaryKeyUrlParams() ?>) ?]">Edit</a> 
     15&nbsp; 
     16<a href="[?php echo url_for('<?php echo $this->getModuleName() ?>/index') ?]">List</a> 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php

    r6097 r6882  
    3232    $this->addOptions(array( 
    3333      new sfCommandOption('theme', null, sfCommandOption::PARAMETER_REQUIRED, 'The theme name', 'default'), 
     34      new sfCommandOption('generate-in-cache', null, sfCommandOption::PARAMETER_NONE, 'Generate the module in cache'), 
     35      new sfCommandOption('non-atomic-actions', null, sfCommandOption::PARAMETER_NONE, 'Generate non atomic actions'), 
     36      new sfCommandOption('non-verbose-templates', null, sfCommandOption::PARAMETER_NONE, 'Generate non verbose templates'), 
     37      new sfCommandOption('with-show', null, sfCommandOption::PARAMETER_NONE, 'Generate a show method'), 
     38      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), 
    3439    )); 
    3540 
     
    4651The task creates a [%module%|COMMENT] module in the [%application%|COMMENT] application 
    4752for the model class [%model%|COMMENT]. 
     53 
     54You can also create an empty module that inherits its actions and templates from 
     55a runtime generated module in [%sf_app_cache_dir%/modules/auto%module%|COMMENT] by 
     56using the [--generate-in-cache|COMMENT] option: 
     57 
     58  [./symfony propel:generate-crud --generate-in-cache frontend article Article|INFO] 
    4859 
    4960The generator can use a customized theme by using the [--theme|COMMENT] option: 
     
    6273    $properties = parse_ini_file(sfConfig::get('sf_config_dir').'/properties.ini', true); 
    6374 
    64     // generate module 
    65     $tmpDir = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true)); 
    66     sfConfig::set('sf_module_cache_dir', $tmpDir); 
    67     $generatorManager = new sfGeneratorManager(); 
    68     $generatorManager->generate('sfPropelCrudGenerator', array('model_class' => $arguments['model'], 'moduleName' => $arguments['module'], 'theme' => $options['theme'])); 
    69  
    70     $moduleDir = sfConfig::get('sf_root_dir').'/'.sfConfig::get('sf_apps_dir_name').'/'.$arguments['application'].'/'.sfConfig::get('sf_app_module_dir_name').'/'.$arguments['module']; 
    71  
    72     // copy our generated module 
    73     $this->filesystem->mirror($tmpDir.'/auto'.ucfirst($arguments['module']), $moduleDir, sfFinder::type('any')); 
    74  
    75     // change module name 
    76     $this->filesystem->replaceTokens($moduleDir.'/actions/actions.class.php', '', '', array('auto'.ucfirst($arguments['module']) => $arguments['module'])); 
    77  
    78     $constants = array( 
     75    $this->constants = array( 
    7976      'PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 
    8077      'APP_NAME'     => $arguments['application'], 
     
    8481    ); 
    8582 
     83    $method = $options['generate-in-cache'] ? 'executeInit' : 'executeGenerate'; 
     84 
     85    $this->$method($arguments, $options); 
     86  } 
     87 
     88  protected function executeGenerate($arguments = array(), $options = array()) 
     89  { 
     90    $this->bootstrapSymfony($arguments['application'], $options['env'], true); 
     91 
     92    sfSimpleAutoload::getInstance()->unregister(); 
     93    sfSimpleAutoload::getInstance()->register(); 
     94 
     95    $databaseManager = new sfDatabaseManager(); 
     96 
     97    // generate module 
     98    $tmpDir = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true)); 
     99    sfConfig::set('sf_module_cache_dir', $tmpDir); 
     100    $generatorManager = new sfGeneratorManager(); 
     101    $generatorManager->generate('sfPropelCrudGenerator', array( 
     102      'model_class'           => $arguments['model'], 
     103      'moduleName'            => $arguments['module'], 
     104      'theme'                 => $options['theme'], 
     105      'non_atomic_actions'    => $options['non-atomic-actions'], 
     106      'non_verbose_templates' => $options['non-verbose-templates'], 
     107      'with_show'             => $options['with-show'], 
     108    )); 
     109 
     110    $moduleDir = sfConfig::get('sf_root_dir').'/'.sfConfig::get('sf_apps_dir_name').'/'.$arguments['application'].'/'.sfConfig::get('sf_app_module_dir_name').'/'.$arguments['module']; 
     111 
     112    // copy our generated module 
     113    $this->filesystem->mirror($tmpDir.'/auto'.ucfirst($arguments['module']), $moduleDir, sfFinder::type('any')); 
     114 
     115    if (!$options['with-show']) 
     116    { 
     117      $this->filesystem->remove($moduleDir.'/templates/showSuccess.php'); 
     118    } 
     119 
     120    // change module name 
     121    $this->filesystem->replaceTokens($moduleDir.'/actions/actions.class.php', '', '', array('auto'.ucfirst($arguments['module']) => $arguments['module'])); 
     122 
    86123    // customize php and yml files 
    87124    $finder = sfFinder::type('file')->name('*.php', '*.yml'); 
    88     $this->filesystem->replaceTokens($finder->in($moduleDir), '##', '##', $constants); 
     125    $this->filesystem->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants); 
    89126 
    90127    // create basic test 
     
    92129 
    93130    // customize test file 
    94     $this->filesystem->replaceTokens(sfConfig::get('sf_root_dir').'/test/functional/'.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php', '##', '##', $constants); 
     131    $this->filesystem->replaceTokens(sfConfig::get('sf_root_dir').'/test/functional/'.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php', '##', '##', $this->constants); 
    95132 
    96133    // delete temp files 
    97134    $this->filesystem->remove(sfFinder::type('any')->in($tmpDir)); 
    98135  } 
     136 
     137  protected function executeInit($arguments = array(), $options = array()) 
     138  { 
     139    $moduleDir = sfConfig::get('sf_root_dir').'/'.sfConfig::get('sf_apps_dir_name').'/'.$arguments['application'].'/'.sfConfig::get('sf_app_module_dir_name').'/'.$arguments['module']; 
     140 
     141    // create basic application structure 
     142    $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 
     143    $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 
     144    foreach ($dirs as $dir) 
     145    { 
     146      if (is_dir($dir)) 
     147      { 
     148        $this->filesystem->mirror($dir, $moduleDir, $finder); 
     149        break; 
     150      } 
     151    } 
     152 
     153    // create basic test 
     154    $this->filesystem->copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/module/test/actionsTest.php', sfConfig::get('sf_root_dir').'/test/functional/'.$arguments['application'].'/'.$arguments['module'].'ActionsTest.php'); 
     155 
     156    // customize test file 
     157    $this->filesystem->replaceTokens(sfConfig::get('sf_root_dir').'/test/functional/'.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php', '##', '##', $this->constants); 
     158 
     159    // customize php and yml files 
     160    $finder = sfFinder::type('file')->name('*.php', '*.yml'); 
     161    $this->constants['CONFIG'] = sprintf("    non_atomic_actions:    %s\n    non_verbose_templates: %s\n    with_show:             %s", 
     162      $options['non-atomic-actions'] ? 'true' : 'false', 
     163      $options['non-verbose-templates'] ? 'true' : 'false', 
     164      $options['with-show'] ? 'true' : 'false' 
     165    ); 
     166    $this->filesystem->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants); 
     167  } 
    99168} 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/browseTest.php

    r6482 r6882  
    6666 
    6767  // first line 
    68   checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td', '1', array('position' => 0))-> 
    69   checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td', 'foo title', array('position' => 1))-> 
    70   checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td', 'bar body', array('position' => 2))-> 
    71   checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td img', true, array('position' => 3))-> 
    72   checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td', '1', array('position' => 4))-> 
     68  checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(0)', '1')-> 
     69  checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(1)', 'foo title')-> 
     70  checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(2)', 'bar body')-> 
     71  checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(3) img', true)-> 
     72  checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(4)', '1')-> 
    7373  checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td a[href$="/article/edit/id/1"]', '1')-> // clickable 
    7474 
    7575  // second line 
    76   checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', '2', array('position' => 0))-> 
    77   checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', 'foo foo title', array('position' => 1))-> 
    78   checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', 'bar bar body', array('position' => 2))-> 
    79   checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td img', false, array('position' => 3))-> 
    80   checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', '2', array('position' => 4))-> 
     76  checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(0)', '2')-> 
     77  checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(1)', 'foo foo title')-> 
     78  checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(2)', 'bar bar body')-> 
     79  checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(3) img', false)-> 
     80  checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(4)', '2')-> 
    8181  checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td a[href$="/article/edit/id/2"]', '2')-> 
    8282 
     
    158158  checkResponseElement('body form#sf_admin_edit_form input[name="article[online]"][id="article_online"][type="checkbox"][checked="checked"]', true)-> 
    159159  checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"]', true)-> 
    160   checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="1"]', '1')-> 
    161   checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="2"]', '2')-> 
     160  checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="1"]', 'Category 1')-> 
     161  checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="2"]', 'Category 2')-> 
    162162  checkResponseElement('body form#sf_admin_edit_form input[name="article[created_at]"][id="article_created_at"][value*="-"]')-> 
    163163 
     
    187187  checkResponseElement('#article_body', 'my body')-> 
    188188  checkResponseElement('input[id="article_online"][checked="checked"]', true)-> 
    189   checkResponseElement('#article_category_id option[selected="selected"]', '2') 
     189  checkResponseElement('#article_category_id option[selected="selected"]', 'Category 2') 
    190190; 
    191191 
     
    229229  checkResponseElement('input[id="article_title"][value="new title"]')-> 
    230230  checkResponseElement('#article_body', 'new body')-> 
    231   checkResponseElement('#article_category_id option[selected="selected"]', '2')-> 
     231  checkResponseElement('#article_category_id option[selected="selected"]', 'Category 2')-> 
    232232 
    233233  // check list 
    234234  getAndCheck('article', 'list')-> 
    235   checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', '', array('position' => 7))-> 
     235  checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(7)', '')-> 
    236236 
    237237  // nb lines 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/config/schema.xml

    r5103 r6882  
    44  <table name="article"> 
    55    <column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" /> 
    6     <column name="title" type="varchar" size="255" /> 
     6    <column name="title" type="varchar" size="255" required="true" /> 
    77    <column name="body" type="longvarchar" /> 
    88    <column name="online" type="boolean" /> 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/Book.php

    r5103 r6882  
    1010class Book extends BaseBook 
    1111{ 
     12  public function __toString() 
     13  { 
     14    return $this->getName(); 
     15  } 
    1216} 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/Category.php

    r5103 r6882  
    1010class Category extends BaseCategory 
    1111{ 
     12  public function __toString() 
     13  { 
     14    return $this->getName(); 
     15  } 
    1216} 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/map/ArticleMapBuilder.php

    r5103 r6882  
    3535    $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); 
    3636 
    37     $tMap->addColumn('TITLE', 'Title', 'string', CreoleTypes::VARCHAR, false, 255); 
     37    $tMap->addColumn('TITLE', 'Title', 'string', CreoleTypes::VARCHAR, true, 255); 
    3838 
    3939    $tMap->addColumn('BODY', 'Body', 'string', CreoleTypes::LONGVARCHAR, false, null); 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/om/BaseArticle.php

    r5103 r6882  
    676676  public function getCategory($con = null) 
    677677  { 
    678         include_once 'lib/model/om/BaseCategoryPeer.php'; 
    679  
    680678    if ($this->aCategory === null && ($this->category_id !== null)) { 
    681  
    682       $this->aCategory = CategoryPeer::retrieveByPK($this->category_id, $con); 
     679            $this->aCategory = CategoryPeer::retrieveByPK($this->category_id, $con); 
    683680 
    684681       
     
    706703  public function getBook($con = null) 
    707704  { 
    708         include_once 'lib/model/om/BaseBookPeer.php'; 
    709  
    710705    if ($this->aBook === null && ($this->book_id !== null)) { 
    711  
    712       $this->aBook = BookPeer::retrieveByPK($this->book_id, $con); 
     706            $this->aBook = BookPeer::retrieveByPK($this->book_id, $con); 
    713707 
    714708       
     
    728722  public function getAuthorArticles($criteria = null, $con = null) 
    729723  { 
    730         include_once 'lib/model/om/BaseAuthorArticlePeer.php'; 
    731     if ($criteria === null) { 
     724        if ($criteria === null) { 
    732725      $criteria = new Criteria(); 
    733726    } 
     
    766759  public function countAuthorArticles($criteria = null, $distinct = false, $con = null) 
    767760  { 
    768         include_once 'lib/model/om/BaseAuthorArticlePeer.php'; 
    769     if ($criteria === null) { 
     761        if ($criteria === null) { 
    770762      $criteria = new Criteria(); 
    771763    } 
     
    791783  public function getAuthorArticlesJoinAuthor($criteria = null, $con = null) 
    792784  { 
    793         include_once 'lib/model/om/BaseAuthorArticlePeer.php'; 
    794     if ($criteria === null) { 
     785        if ($criteria === null) { 
    795786      $criteria = new Criteria(); 
    796787    } 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/om/BaseArticlePeer.php

    r5103 r6882  
    6767  public static function getMapBuilder() 
    6868  { 
    69     include_once 'lib/model/map/ArticleMapBuilder.php'; 
    7069    return BasePeer::getMapBuilder('lib.model.map.ArticleMapBuilder'); 
    7170  } 
     
    830829  } 
    831830} else { 
    832       require_once 'lib/model/map/ArticleMapBuilder.php'; 
    833   Propel::registerMapBuilder('lib.model.map.ArticleMapBuilder'); 
     831      Propel::registerMapBuilder('lib.model.map.ArticleMapBuilder'); 
    834832} 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/om/BaseAuthor.php

    r5103 r6882  
    359359  public function getAuthorArticles($criteria = null, $con = null) 
    360360  { 
    361         include_once 'lib/model/om/BaseAuthorArticlePeer.php'; 
    362     if ($criteria === null) { 
     361        if ($criteria === null) { 
    363362      $criteria = new Criteria(); 
    364363    } 
     
    397396  public function countAuthorArticles($criteria = null, $distinct = false, $con = null) 
    398397  { 
    399         include_once 'lib/model/om/BaseAuthorArticlePeer.php'; 
    400     if ($criteria === null) { 
     398        if ($criteria === null) { 
    401399      $criteria = new Criteria(); 
    402400    } 
     
    422420  public function getAuthorArticlesJoinArticle($criteria = null, $con = null) 
    423421  { 
    424         include_once 'lib/model/om/BaseAuthorArticlePeer.php'; 
    425     if ($criteria === null) { 
     422        if ($criteria === null) { 
    426423      $criteria = new Criteria(); 
    427424    } 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/om/BaseAuthorArticle.php

    r5103 r6882  
    418418  public function getAuthor($con = null) 
    419419  { 
    420         include_once 'lib/model/om/BaseAuthorPeer.php'; 
    421  
    422420    if ($this->aAuthor === null && ($this->author_id !== null)) { 
    423  
    424       $this->aAuthor = AuthorPeer::retrieveByPK($this->author_id, $con); 
     421            $this->aAuthor = AuthorPeer::retrieveByPK($this->author_id, $con); 
    425422 
    426423       
     
    448445  public function getArticle($con = null) 
    449446  { 
    450         include_once 'lib/model/om/BaseArticlePeer.php'; 
    451  
    452447    if ($this->aArticle === null && ($this->article_id !== null)) { 
    453  
    454       $this->aArticle = ArticlePeer::retrieveByPK($this->article_id, $con); 
     448            $this->aArticle = ArticlePeer::retrieveByPK($this->article_id, $con); 
    455449 
    456450       
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/om/BaseAuthorArticlePeer.php

    r5103 r6882  
    5252  public static function getMapBuilder() 
    5353  { 
    54     include_once 'lib/model/map/AuthorArticleMapBuilder.php'; 
    5554    return BasePeer::getMapBuilder('lib.model.map.AuthorArticleMapBuilder'); 
    5655  } 
     
    805804  } 
    806805} else { 
    807       require_once 'lib/model/map/AuthorArticleMapBuilder.php'; 
    808   Propel::registerMapBuilder('lib.model.map.AuthorArticleMapBuilder'); 
     806      Propel::registerMapBuilder('lib.model.map.AuthorArticleMapBuilder'); 
    809807} 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/model/om/BaseAuthorPeer.php

    r5103 r6882  
    4949  public static function getMapBuilder() 
    5050  { 
    51     include_once 'lib/model/map/AuthorMapBuilder.php'; 
    5251    return BasePeer::getMapBuilder('lib.model.map.AuthorMapBuilder'); 
    5352  } 
     
    364363  } 
    365364} else { 
    366       require_once 'lib/model/map/AuthorMapBuilder.php'; 
    367   Propel::registerMapBuilder('lib.model.map.AuthorMapBuilder'); 
     365      Propel::registerMapBuilder('lib.model.map.AuthorMapBuilder'); 
    368366} 
  • branches/1.1/lib/plugins/sfPropel