[Alba-desarrollo] SVN Alba r5409 - prosistem/alba/trunk/alba/plugins/albaTasks/data/tasks

commits en pressenter.com.ar commits en pressenter.com.ar
Mie Ene 16 22:02:00 CET 2008


Author: josx
Date: 2008-01-16 19:02:00 -0200 (Wed, 16 Jan 2008)
New Revision: 5409

Modified:
   prosistem/alba/trunk/alba/plugins/albaTasks/data/tasks/albaTasks.php
Log:
Se agrega el metodo load data ya que el del symfony tiene un bug

Modified: prosistem/alba/trunk/alba/plugins/albaTasks/data/tasks/albaTasks.php
===================================================================
--- prosistem/alba/trunk/alba/plugins/albaTasks/data/tasks/albaTasks.php	2008-01-16 20:25:02 UTC (rev 5408)
+++ prosistem/alba/trunk/alba/plugins/albaTasks/data/tasks/albaTasks.php	2008-01-16 21:02:00 UTC (rev 5409)
@@ -9,6 +9,8 @@
 pake_desc('[ALBA-fix] dump data to fixtures directory');
 pake_task('alba-dump-data', 'project_exists');
 
+pake_desc('[ALBA-fix] load data to fixtures directory');
+pake_task('alba-load-data', 'project_exists');
 
 
 function run_alba_list_users( $task, $args ) 
@@ -102,4 +104,71 @@
 }
 
 
+function run_alba_load_data($task, $args)
+{
+  if (!count($args))
+  {
+    throw new Exception('You must provide the app.');
+  }
+
+  $app = $args[0];
+
+  if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app))
+  {
+    throw new Exception('The app "'.$app.'" does not exist.');
+  }
+
+  if (count($args) > 1 && $args[count($args) - 1] == 'append')
+  {
+    array_pop($args);
+    $delete = false;
+  }
+  else
+  {
+    $delete = true;
+  }
+
+  $env = empty($args[1]) ? 'dev' : $args[1];
+
+  // define constants
+  define('SF_ROOT_DIR',    sfConfig::get('sf_root_dir'));
+  define('SF_APP',         $app);
+  define('SF_ENVIRONMENT', $env);
+  define('SF_DEBUG',       true);
+
+  // get configuration
+  require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
+
+  if (count($args) == 1)
+  {
+    if (!$pluginDirs = glob(sfConfig::get('sf_root_dir').'/plugins/*/data'))
+    {
+      $pluginDirs = array();
+    }
+    $fixtures_dirs = pakeFinder::type('dir')->name('fixtures')->in(array_merge($pluginDirs, array(sfConfig::get('sf_data_dir'))));
+  }
+  else
+  {
+    $fixtures_dirs = array_slice($args, 1);
+  }
+
+  $databaseManager = new sfDatabaseManager();
+  $databaseManager->initialize();
+
+  $data = new sfPropelData();
+  $data->setDeleteCurrentData($delete);
+
+  foreach ($fixtures_dirs as $fixtures_dir)
+  {
+    if (!is_readable($fixtures_dir))
+    {
+      continue;
+    }
+
+    pake_echo_action('propel', sprintf('load data from "%s"', $fixtures_dir));
+
+    $data->loadData($fixtures_dir,'alba');
+  }
+}
+
 ?>
\ No newline at end of file




Más información sobre la lista de distribución Alba-desarrollo