Development

Changeset 4624

You must first sign up to be able to contribute.

Changeset 4624

Show
Ignore:
Timestamp:
07/16/07 14:38:05 (1 year ago)
Author:
fabien
Message:

moved some propel-load-data arguments to options (closes #1972)

Before: symfony propel-load-data frontend dev fixtures append
After: symfony propel-load-data frontend --env=dev --dir[]=fixtures --append

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/tasks/sfPakePropel.php

    r4594 r4624  
    283283 * Loads yml data from fixtures directory and inserts into database. 
    284284 * 
    285  * @example symfony load-data frontend 
    286  * @example symfony load-data frontend dev fixtures append 
    287  * 
    288  * @todo replace delete argument with flag -d 
     285 * @example symfony propel-load-data frontend 
     286 * @example symfony --env=dev --dir[]=data/fixtures --append propel-load-data frontend 
    289287 * 
    290288 * @param object $task 
    291  * @param array $args 
     289 * @param array $args 
    292290 */ 
    293 function run_propel_load_data($task, $args
     291function run_propel_load_data($task, $args, $options
    294292{ 
    295293  if (!count($args)) 
     
    302300  if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app)) 
    303301  { 
    304     throw new Exception('The app "'.$app.'" does not exist.'); 
    305   } 
    306  
    307   if (count($args) > 1 && $args[count($args) - 1] == 'append'
     302    throw new Exception(sprintf('The app "%s" does not exist.', $app)); 
     303  } 
     304 
     305  if (isset($options['append'])
    308306  { 
    309307    array_pop($args); 
     
    315313  } 
    316314 
    317   $env = empty($args[1]) ? 'dev' : $args[1]
     315  $env = isset($options['env']) ? $options['env'] : 'dev'
    318316 
    319317  // define constants 
     
    326324  require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'; 
    327325 
    328   if (count($args) == 1) 
     326  if (isset($options['dir[]'])) 
     327  { 
     328    $fixtures_dirs = $options['dir[]']; 
     329  } 
     330  else 
    329331  { 
    330332    if (!$pluginDirs = glob(sfConfig::get('sf_root_dir').'/plugins/*/data')) 
     
    333335    } 
    334336    $fixtures_dirs = pakeFinder::type('dir')->name('fixtures')->in(array_merge($pluginDirs, array(sfConfig::get('sf_data_dir')))); 
    335   } 
    336   else 
    337   { 
    338     $fixtures_dirs = array_slice($args, 1); 
    339337  } 
    340338