*/ require_once sfConfig::get('sf_symfony_lib_dir').'/vendor/pake/pakeColor.class.php'; /** * Klasa umożliwiająca kontrolę nad przebiegiem generowania bazy danych na podstawie schematów *schema.yml * * @package stInstallerPlugin * @subpackage libs * @author Marcin Butlak */ class stPropelGeneratorController { /** * Flaga - buduj bazę danych na podstawie informacji z pliku package-schema-diff.yml * * @var bool */ protected static $schemaDiffBuildControl = false; /** * Flaga - usuwaj tabele podczas ich tworzenia * * @var bool */ protected static $dropStatements = true; protected static $forceRebuild = false; public static function forceRebuild() { self::$forceRebuild = true; } /** * Wyłącz usuwanie tabel podczas ich tworzenia * */ public static function disableDropStatements() { self::showInfo('disabling', 'drop statements on table creation'); self::$dropStatements = false; } /** * Włącz usuwanie tabel podczas ich tworzenia * */ public static function enableDropStatements() { self::showInfo('enabling', 'drop statements on table creation'); self::$dropStatements = true; } /** * Wyłącz budowanie bazy danych na podstawie informacji z pliku package-schema-diff.yml * */ public static function disableSchemaDiffBuildControl() { self::showInfo('disabling', 'schema difference build control'); self::$schemaDiffBuildControl = false; } /** * Włącz budowanie bazy danych na podstawie informacji z pliku package-schema-diff.yml * */ public static function enableSchemaDiffBuildControl() { self::showInfo('enabling', 'schema difference build control'); self::$schemaDiffBuildControl = true; } public static function isSchemaDiffBuildControl() { return self::$schemaDiffBuildControl; } public static function isDropStatements() { return self::$dropStatements; } public static function getPluginDirs() { static $plugin_dirs = null; if (null === $plugin_dirs) { $plugin_dirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'); } return $plugin_dirs; } public static function isDatabaseRebuildNeeded() { return self::$forceRebuild || is_file(sfConfig::get('sf_config_dir').DIRECTORY_SEPARATOR.'schema-diff.yml'); } public static function isForced() { return self::$forceRebuild; } protected static function showInfo($action, $message) { if (pakeApp::get_instance()->get_verbose()) { pakeColor::style('GENERATOR_INFO', array('fg' => 'blue')); $width = 9 + strlen(pakeColor::colorize('', 'GENERATOR_INFO')); echo sprintf('>> %-'.$width.'s %s', pakeColor::colorize($action, 'GENERATOR_INFO'), $message)."\n"; } } } ?>