Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of the symfony package.
5
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php');
12
 
13
/**
14
 * Generates Propel model, SQL, initializes database, and load data.
15
 *
16
 * @package    symfony
17
 * @subpackage propel
18
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
19
 * @version    SVN: $Id: sfPropelBuildAllLoadTask.class.php 23922 2009-11-14 14:58:38Z fabien $
20
 */
21
class sfPropelBuildAllLoadTask extends sfPropelBaseTask
22
{
23
  /**
24
   * @see sfTask
25
   */
26
  protected function configure()
27
  {
28
    $this->addOptions(array(
29
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
30
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
31
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
32
      new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'),
33
      new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms'),
34
      new sfCommandOption('classes-only', 'C', sfCommandOption::PARAMETER_NONE, 'Do not initialize the database'),
35
      new sfCommandOption('phing-arg', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'Arbitrary phing argument'),
36
      new sfCommandOption('append', null, sfCommandOption::PARAMETER_NONE, 'Don\'t delete current data in the database'),
37
      new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'The directories to look for fixtures'),
38
    ));
39
 
40
    $this->namespace = 'propel';
41
    $this->name = 'build-all-load';
42
    $this->briefDescription = 'Generates Propel model and form classes, SQL, initializes the database, and loads data';
43
 
44
    $this->detailedDescription = <<<EOF
45
The [propel:build-all-load|INFO] task is a shortcut for two other tasks:
46
 
47
  [./symfony propel:build-all-load|INFO]
48
 
49
The task is equivalent to:
50
 
51
  [./symfony propel:build-all|INFO]
52
  [./symfony propel:data-load|INFO]
53
 
54
See those tasks' help pages for more information.
55
 
56
To bypass the confirmation, you can pass the [no-confirmation|COMMENT]
57
option:
58
 
59
  [./symfony propel:buil-all-load --no-confirmation|INFO]
60
EOF;
61
  }
62
 
63
  /**
64
   * @see sfTask
65
   */
66
  protected function execute($arguments = array(), $options = array())
67
  {
68
    // load Propel configuration before Phing
69
    $databaseManager = new sfDatabaseManager($this->configuration);
70
 
71
    $buildAll = new sfPropelBuildAllTask($this->dispatcher, $this->formatter);
72
    $buildAll->setCommandApplication($this->commandApplication);
73
    $buildAll->setConfiguration($this->configuration);
74
    $ret = $buildAll->run(array(), array(
75
      'phing-arg'       => $options['phing-arg'],
76
      'skip-forms'      => $options['skip-forms'],
77
      'classes-only'    => $options['classes-only'],
78
      'no-confirmation' => $options['no-confirmation'],
79
    ));
80
 
81
    if (0 == $ret)
82
    {
83
      $loadData = new sfPropelDataLoadTask($this->dispatcher, $this->formatter);
84
      $loadData->setCommandApplication($this->commandApplication);
85
      $loadData->setConfiguration($this->configuration);
86
      $loadData->run($options['dir'], array(
87
        'append' => $options['append'],
88
      ));
89
    }
90
 
91
    $this->cleanup();
92
 
93
    return $ret;
94
  }
95
}