Development

/branches/1.3/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineDataDumpTask.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineDataDumpTask.class.php

Revision 23810, 2.5 kB (checked in by Kris.Wallsmith, 4 years ago)

[1.3] set svn:eol-style property to native and svn:keywords property to Id on all .php files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  * (c) Jonathan H. Wage <jonwage@gmail.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php');
13
14 /**
15  * Dumps data to the fixtures directory.
16  *
17  * @package    symfony
18  * @subpackage doctrine
19  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
20  * @author     Jonathan H. Wage <jonwage@gmail.com>
21  * @version    SVN: $Id$
22  */
23 class sfDoctrineDataDumpTask extends sfDoctrineBaseTask
24 {
25   /**
26    * @see sfTask
27    */
28   protected function configure()
29   {
30     $this->addArguments(array(
31       new sfCommandArgument('target', sfCommandArgument::OPTIONAL, 'The target filename'),
32     ));
33
34     $this->addOptions(array(
35       new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
36       new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
37     ));
38
39     $this->aliases = array('doctrine-dump-data');
40     $this->namespace = 'doctrine';
41     $this->name = 'data-dump';
42     $this->briefDescription = 'Dumps data to the fixtures directory';
43
44     $this->detailedDescription = <<<EOF
45 The [doctrine:data-dump|INFO] task dumps database data:
46
47   [./symfony doctrine:data-dump|INFO]
48
49 The task dumps the database data in [data/fixtures/%target%|COMMENT].
50
51 The dump file is in the YML format and can be reimported by using
52 the [doctrine:data-load|INFO] task.
53
54   [./symfony doctrine:data-load|INFO]
55 EOF;
56   }
57
58   /**
59    * @see sfTask
60    */
61   protected function execute($arguments = array(), $options = array())
62   {
63     $databaseManager = new sfDatabaseManager($this->configuration);
64     $config = $this->getCliConfig();
65
66     $args = array(
67       'data_fixtures_path' => $config['data_fixtures_path'][0],
68     );
69
70     if (!is_dir($args['data_fixtures_path']))
71     {
72       $this->getFilesystem()->mkdirs($args['data_fixtures_path']);
73     }
74
75     if ($arguments['target'])
76     {
77       $filename = $arguments['target'];
78
79       if (!sfToolkit::isPathAbsolute($filename))
80       {
81         $filename = $args['data_fixtures_path'].'/'.$filename;
82       }
83
84       $this->getFilesystem()->mkdirs(dirname($filename));
85
86       $args['data_fixtures_path'] = $filename;
87     }
88
89     $this->logSection('doctrine', sprintf('dumping data to fixtures to "%s"', $args['data_fixtures_path']));
90     $this->callDoctrineCli('dump-data', $args);
91   }
92 }
Note: See TracBrowser for help on using the browser.