symfony task doctrine:custom-build-sql

5 февр. 2013 г., 10:05:27  996


Нашел небольшой класс для генерации sql файла для моделей sfDoctrineCustomBuildSqlTask.class.php

<!--?php


/**
 * Create SQL for the current model.
 *
 * @package    symfony
 * @subpackage doctrine
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com-->
 * @author     Jonathan H. Wage <jonwage@gmail.com>
 * @version    SVN: $Id: sfDoctrineBuildSqlTask.class.php 23922 2009-11-14 14:58:38Z fabien $
 */
class sfDoctrineCustomBuildSqlTask extends sfDoctrineBaseTask
{
  /**
   * @see sfTask
   */
  protected function configure()
  {
    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
    ));

    $this->namespace = 'doctrine';
    $this->name = 'custom-build-sql';
    $this->briefDescription = 'Creates SQL for the current model';

    $this->detailedDescription = <<<eof .="" :="" arguments="array()," config="" configured="" creates="" creation:="" database="" doctrine.database="mysql|INFO]" for="" function="" generated="" in="" is="" optimized="" options="array())" protected="" see="" sftask="" sql="" statements="" symfony="" table="" task="" the="" this-="">logSection('doctrine', 'generating sql for models');

    $path = sfConfig::get('sf_data_dir').'/sql';
    if (!is_dir($path)) {
      $this->getFilesystem()->mkdirs($path);
    }
    
    $args['models_path'] = array(sfConfig::get('sf_lib_dir').'/package', sfConfig::get('sf_lib_dir').'/model');

    $databaseManager = new sfDatabaseManager($this->configuration);
    $this->callDoctrineCli('generate-sql', $args);
  }
}
</eof></jonwage@gmail.com>