Development

/branches/1.2/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineDropDbTask.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineDropDbTask.class.php

Revision 14213, 2.1 kB (checked in by Jonathan.Wage, 5 years ago)

[1.2] sfDoctrinePlugin: fixes issue with application option in tasks (closes #5238)

  • Property svn:keywords set to Id Date Author Revision HeadURL
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  * Drops database for current model.
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 sfDoctrineDropDbTask extends sfDoctrineBaseTask
24 {
25   /**
26    * @see sfTask
27    */
28   protected function configure()
29   {
30     $this->addOptions(array(
31       new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
32       new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
33       new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Whether to force dropping of the database')
34     ));
35
36     $this->aliases = array('doctrine-drop-db');
37     $this->namespace = 'doctrine';
38     $this->name = 'drop-db';
39     $this->briefDescription = 'Drops database for current model';
40
41     $this->detailedDescription = <<<EOF
42 The [doctrine:drop-db|INFO] task drops the database:
43
44   [./symfony doctrine:drop-db|INFO]
45
46 The task read connection information in [config/doctrine/databases.yml|COMMENT]:
47 EOF;
48   }
49
50   /**
51    * @see sfTask
52    */
53   protected function execute($arguments = array(), $options = array())
54   {
55     if (
56       !$options['no-confirmation']
57       &&
58       !$this->askConfirmation(array('This command will remove all data in your database.', 'Are you sure you want to proceed? (y/N)'), null, false)
59     )
60     {
61       $this->logSection('doctrine', 'task aborted');
62
63       return 1;
64     }
65
66     $this->logSection('doctrine', 'dropping databases');
67
68     $databaseManager = new sfDatabaseManager($this->configuration);
69     $this->callDoctrineCli('drop-db', array('force' => true));
70   }
71 }
Note: See TracBrowser for help on using the browser.