initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

View File

@ -0,0 +1,49 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_task('project_exists');
pake_task('app_exists', 'project_exists');
pake_task('module_exists', 'app_exists');
function run_project_exists($task, $args)
{
if (!file_exists('symfony'))
{
throw new Exception('you must be in a symfony project directory');
}
pake_properties('config/properties.ini');
}
function run_app_exists($task, $args)
{
if (!count($args))
{
throw new Exception('you must provide your application name');
}
if (!is_dir(getcwd().'/apps/'.$args[0]))
{
throw new Exception('application "'.$args[0].'" does not exist');
}
}
function run_module_exists($task, $args)
{
if (count($args) < 2)
{
throw new Exception('you must provide your module name');
}
if (!is_dir(getcwd().'/apps/'.$args[0].'/modules/'.$args[1]))
{
throw new Exception('module "'.$args[1].'" does not exist');
}
}

View File

@ -0,0 +1,82 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('synchronise project with another machine');
pake_task('sync', 'project_exists');
function run_sync($task, $args)
{
if (!count($args))
{
throw new Exception('You must provide an environment to synchronize.');
}
$env = $args[0];
$dryrun = isset($args[1]) ? $args[1] : false;
if (!file_exists('config/rsync_exclude.txt'))
{
throw new Exception('You must create a rsync_exclude file for your project.');
}
$host = $task->get_property('host', $env);
$dir = $task->get_property('dir', $env);
try
{
$user = $task->get_property('user', $env).'@';
}
catch (pakeException $e)
{
$user = '';
}
if (substr($dir, -1) != '/')
{
$dir .= '/';
}
$ssh = 'ssh';
try
{
$port = $task->get_property('port', $env);
$ssh = '"ssh -p'.$port.'"';
}
catch (pakeException $e) {}
try
{
$parameters = $task->get_property('parameters', $env);
}
catch (pakeException $e)
{
$parameters = '-azC --force --delete';
if (file_exists('config/rsync_exclude.txt'))
{
$parameters .= ' --exclude-from=config/rsync_exclude.txt';
}
if (file_exists('config/rsync_include.txt'))
{
$parameters .= ' --include-from=config/rsync_include.txt';
}
if (file_exists('config/rsync.txt'))
{
$parameters .= ' --files-from=config/rsync.txt';
}
}
$dry_run = ($dryrun == 'go' || $dryrun == 'ok') ? '' : '--dry-run';
$cmd = "rsync --progress $dry_run $parameters -e $ssh ./ $user$host:$dir";
echo pake_sh($cmd);
}

View File

@ -0,0 +1,284 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('initialize a new symfony project');
pake_task('init-project');
pake_alias('new', 'init-project');
pake_desc('initialize a new symfony application');
pake_task('init-app', 'project_exists');
pake_alias('app', 'init-app');
pake_desc('initialize a new symfony module');
pake_task('init-module', 'app_exists');
pake_alias('module', 'init-module');
pake_desc('initialize a new symfony batch script');
pake_task('init-batch', 'project_exists');
pake_alias('batch', 'init-batch');
pake_desc('initialize a new symfony controller script');
pake_task('init-controller', 'app_exists');
pake_alias('controller', 'init-controller');
function run_init_project($task, $args)
{
if (file_exists('symfony'))
{
throw new Exception('A symfony project already exists in this directory.');
}
if (!count($args))
{
throw new Exception('You must provide a project name.');
}
$project_name = $args[0];
$sf_root_dir = sfConfig::get('sf_root_dir');
// create basic project structure
$finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf');
pake_mirror($finder, sfConfig::get('sf_symfony_data_dir').'/skeleton/project', $sf_root_dir);
$finder = pakeFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini');
pake_replace_tokens($finder, $sf_root_dir, '##', '##', array('PROJECT_NAME' => $project_name));
$finder = pakeFinder::type('file')->name('propel.ini');
pake_replace_tokens($finder, $sf_root_dir, '##', '##', array('PROJECT_DIR' => $sf_root_dir));
// update config/config.php
pake_replace_tokens('config.php', sfConfig::get('sf_config_dir'), '##', '##', array(
'SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'),
'SYMFONY_DATA_DIR' => sfConfig::get('sf_symfony_data_dir'),
));
run_fix_perms($task, $args);
}
function run_init_app($task, $args)
{
if (!count($args))
{
throw new Exception('You must provide your application name.');
}
$app = $args[0];
$sf_root_dir = sfConfig::get('sf_root_dir');
$app_dir = $sf_root_dir.'/'.sfConfig::get('sf_apps_dir_name').'/'.$app;
if (is_dir($app_dir))
{
throw new Exception(sprintf('The directory "%s" already exists.', $app_dir));
}
// create basic application structure
$finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf');
pake_mirror($finder, sfConfig::get('sf_symfony_data_dir').'/skeleton/app/app', $app_dir);
// create $app.php or index.php if it is our first app
$index_name = 'index';
$first_app = file_exists(sfConfig::get('sf_web_dir').'/index.php') ? false : true;
if (!$first_app)
{
$index_name = $app;
}
// set no_script_name value in settings.yml for production environment
$finder = pakeFinder::type('file')->name('settings.yml');
pake_replace_tokens($finder, $app_dir.'/'.sfConfig::get('sf_app_config_dir_name'), '##', '##', array('NO_SCRIPT_NAME' => ($first_app ? 'on' : 'off')));
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/app/web/index.php', sfConfig::get('sf_web_dir').'/'.$index_name.'.php');
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/app/web/index_dev.php', sfConfig::get('sf_web_dir').'/'.$app.'_dev.php');
$finder = pakeFinder::type('file')->name($index_name.'.php', $app.'_dev.php');
pake_replace_tokens($finder, sfConfig::get('sf_web_dir'), '##', '##', array('APP_NAME' => $app));
run_fix_perms($task, $args);
// create test dir
pake_mkdirs($sf_root_dir.'/test/functional/'.$app);
}
function run_init_module($task, $args)
{
if (count($args) < 2)
{
throw new Exception('You must provide your module name.');
}
$app = $args[0];
$module = $args[1];
$sf_root_dir = sfConfig::get('sf_root_dir');
$module_dir = $sf_root_dir.'/'.sfConfig::get('sf_apps_dir_name').'/'.$app.'/'.sfConfig::get('sf_app_module_dir_name').'/'.$module;
if (is_dir($module_dir))
{
throw new Exception(sprintf('The directory "%s" already exists.', $module_dir));
}
try
{
$author_name = $task->get_property('author', 'symfony');
}
catch (pakeException $e)
{
$author_name = 'Your name here';
}
$constants = array(
'PROJECT_NAME' => $task->get_property('name', 'symfony'),
'APP_NAME' => $app,
'MODULE_NAME' => $module,
'AUTHOR_NAME' => $author_name,
);
if (is_readable(sfConfig::get('sf_data_dir').'/skeleton/module'))
{
$sf_skeleton_dir = sfConfig::get('sf_data_dir').'/skeleton/module';
}
else
{
$sf_skeleton_dir = sfConfig::get('sf_symfony_data_dir').'/skeleton/module';
}
// create basic application structure
$finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf');
pake_mirror($finder, $sf_skeleton_dir.'/module', $module_dir);
// create basic test
pake_copy($sf_skeleton_dir.'/test/actionsTest.php', $sf_root_dir.'/test/functional/'.$app.'/'.$module.'ActionsTest.php');
// customize test file
pake_replace_tokens($module.'ActionsTest.php', $sf_root_dir.'/test/functional/'.$app, '##', '##', $constants);
// customize php and yml files
$finder = pakeFinder::type('file')->name('*.php', '*.yml');
pake_replace_tokens($finder, $module_dir, '##', '##', $constants);
}
function run_init_batch($task, $args)
{
// handling two required arguments (application and batch name)
if (count($args) < 1)
{
throw new Exception('You must provide the batch skeleton name');
}
// TODO: add finder here to locate batch skeleton locally or in symfony dirs, and send path to skeletons function
$batch = '_batch_'.$args[0];
if (!function_exists($batch))
{
throw new Exception(sprintf('The specified batch "%s" does not exist.', $args[0]));
}
$batch($task, $args);
if (!file_exists(sfConfig::get('sf_symfony_data_dir').'/skeleton/batch/'.$args[0].'.php'))
{
throw new Exception('The skeleton you specified could not be found.');
}
}
function _batch_default($task, $args)
{
if (count($args) < 2)
{
throw new Exception('You must provide the destination script name');
}
if (count($args) < 3)
{
throw new Exception('You must provide the application name');
}
$batch = $args[1];
$app = $args[2];
// handling two optional arguments (environment and debug)
$env = isset($args[3]) ? $args[3] : 'dev';
$debug = isset($args[4]) ? $args[4] : true;
$constants = array(
'PROJECT_NAME' => $task->get_property('name', 'symfony'),
'APP_NAME' => $app,
'BATCH_NAME' => $batch,
'ENV_NAME' => $env,
'DEBUG' => (boolean) $debug,
);
$sf_bin_dir = sfConfig::get('sf_bin_dir');
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/batch/default.php', $sf_bin_dir.'/'.$batch.'.php');
pake_replace_tokens($batch.'.php', $sf_bin_dir, '##', '##', $constants);
}
function _batch_rotate_log($task, $args)
{
if (count($args) < 2)
{
throw new Exception('You must provide the application');
}
if (count($args) < 3)
{
throw new Exception('You must provide the environment');
}
$app = $args[1];
$env = $args[2];
$batch = 'rotate_log_'.$app.'_'.$env;
// handling two optional arguments (environment and debug)
$env = isset($args[3]) ? $args[3] : 'dev';
$debug = isset($args[4]) ? $args[4] : true;
$constants = array(
'PROJECT_NAME' => $task->get_property('name', 'symfony'),
'APP_NAME' => $app,
'BATCH_NAME' => $batch,
'ENV_NAME' => $env,
'DEBUG' => (boolean) $debug,
);
$sf_bin_dir = sfConfig::get('sf_bin_dir');
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/batch/rotate_log.php', $sf_bin_dir.'/'.$batch.'.php');
pake_replace_tokens($batch.'.php', $sf_bin_dir, '##', '##', $constants);
}
function run_init_controller($task, $args)
{
// handling two required arguments (application and batch name)
if (count($args) < 2)
{
throw new Exception('You must provide the environment name');
}
$app = $args[0];
$env = $args[1];
// handling two optional arguments (environment and debug)
$controller = isset($args[2]) ? $args[2] : $app.'_'.$env;
$debug = isset($args[3]) ? $args[3] : true;
$constants = array(
'PROJECT_NAME' => $task->get_property('name', 'symfony'),
'APP_NAME' => $app,
'CONTROLLER_NAME' => $controller,
'ENV_NAME' => $env,
'DEBUG' => (boolean) $debug,
);
$sf_web_dir = sfConfig::get('sf_web_dir');
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/controller/controller.php', $sf_web_dir.'/'.$controller.'.php');
pake_replace_tokens($controller.'.php', $sf_web_dir, '##', '##', $constants);
}

338
data/symfony/tasks/sfPakeMisc.php Executable file
View File

@ -0,0 +1,338 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('clear cached information');
pake_task('clear-cache', 'project_exists');
pake_alias('cc', 'clear-cache');
pake_desc('clear controllers');
pake_task('clear-controllers', 'project_exists');
pake_desc('fix directories permissions');
pake_task('fix-perms', 'project_exists');
pake_desc('rotates an applications log files');
pake_task('log-rotate', 'app_exists');
pake_desc('purges an applications log files');
pake_task('log-purge', 'project_exists');
pake_desc('enables an application in a given environment');
pake_task('enable', 'app_exists');
pake_desc('disables an application in a given environment');
pake_task('disable', 'app_exists');
/**
* fixes permissions in a symfony project
*
* @example symfony fix-perms
*
* @param object $task
* @param array $args
*/
function run_fix_perms($task, $args)
{
$sf_root_dir = sfConfig::get('sf_root_dir');
pake_chmod(sfConfig::get('sf_cache_dir_name'), $sf_root_dir, 0777);
pake_chmod(sfConfig::get('sf_log_dir_name'), $sf_root_dir, 0777);
pake_chmod(sfConfig::get('sf_web_dir_name').DIRECTORY_SEPARATOR.sfConfig::get('sf_upload_dir_name'), $sf_root_dir, 0777);
pake_chmod('symfony', $sf_root_dir, 0777);
$dirs = array(sfConfig::get('sf_cache_dir_name'), sfConfig::get('sf_web_dir_name').DIRECTORY_SEPARATOR.sfConfig::get('sf_upload_dir_name'), sfConfig::get('sf_log_dir_name'));
$dir_finder = pakeFinder::type('dir')->ignore_version_control();
$file_finder = pakeFinder::type('file')->ignore_version_control();
foreach ($dirs as $dir)
{
pake_chmod($dir_finder, $dir, 0777);
pake_chmod($file_finder, $dir, 0666);
}
}
/**
* clears symfony project cache
*
* @example symfony clear-cache
* @example symfony cc
*
* @param object $task
* @param array $args
*/
function run_clear_cache($task, $args)
{
if (!file_exists('cache'))
{
throw new Exception('Cache directory does not exist.');
}
$cache_dir = sfConfig::get('sf_cache_dir_name');
// app
$main_app = '';
if (isset($args[0]))
{
$main_app = $args[0];
}
// type (template, i18n or config)
$main_type = '';
if (isset($args[1]))
{
$main_type = $args[1];
}
// declare type that must be cleaned safely (with a lock file during cleaning)
$safe_types = array(sfConfig::get('sf_app_config_dir_name'), sfConfig::get('sf_app_i18n_dir_name'));
// finder to remove all files in a cache directory
$finder = pakeFinder::type('file')->ignore_version_control()->discard('.sf');
// finder to find directories (1 level) in a directory
$dir_finder = pakeFinder::type('dir')->ignore_version_control()->discard('.sf')->maxdepth(0)->relative();
// iterate through applications
$apps = array();
if ($main_app)
{
$apps[] = $main_app;
}
else
{
$apps = $dir_finder->in($cache_dir);
}
foreach ($apps as $app)
{
if (!is_dir($cache_dir.'/'.$app))
{
continue;
}
// remove cache for all environments
foreach ($dir_finder->in($cache_dir.'/'.$app) as $env)
{
// which types?
$types = array();
if ($main_type)
{
$types[] = $main_type;
}
else
{
$types = $dir_finder->in($cache_dir.'/'.$app.'/'.$env);
}
$sf_root_dir = sfConfig::get('sf_root_dir');
foreach ($types as $type)
{
$sub_dir = $cache_dir.'/'.$app.'/'.$env.'/'.$type;
if (!is_dir($sub_dir))
{
continue;
}
// remove cache files
if (in_array($type, $safe_types))
{
$lock_name = $app.'_'.$env;
_safe_cache_remove($finder, $sub_dir, $lock_name);
}
else
{
pake_remove($finder, $sf_root_dir.'/'.$sub_dir);
}
}
}
}
}
/**
* clears all controllers in your web directory other than one running in a produciton environment
*
* @example symfony clear-controllers
*
* @param object $task
* @param array $args
*/
function run_clear_controllers($task, $args)
{
$web_dir = sfConfig::get('sf_web_dir');
$app_dir = sfConfig::get('sf_app_dir');
$apps = count($args) > 1 ? $args : null;
// get controller
$controllers = pakeFinder::type('file')->ignore_version_control()->maxdepth(1)->name('*.php')->in($web_dir);
foreach ($controllers as $controller)
{
$contents = file_get_contents($controller);
preg_match('/\'SF_APP\',[\s]*\'(.*)\'\)/', $contents, $found_app);
preg_match('/\'SF_ENVIRONMENT\',[\s]*\'(.*)\'\)/', $contents, $env);
// remove file if it has found an application and the environment is not production
if (isset($found_app[1]) && isset($env[1]) && $env[1] != 'prod')
{
pake_remove($controller, '');
}
}
}
/**
* safely removes directory via pake
*
* @param object $finder
* @param string $sub_dir
* @param string $lock_name
*/
function _safe_cache_remove($finder, $sub_dir, $lock_name)
{
$sf_root_dir = sfConfig::get('sf_root_dir');
// create a lock file
pake_touch($sf_root_dir.'/'.$lock_name.'.lck', '');
// change mode so the web user can remove it if we die
pake_chmod($lock_name.'.lck', $sf_root_dir, 0777);
// remove cache files
pake_remove($finder, $sf_root_dir.'/'.$sub_dir);
// release lock
pake_remove($sf_root_dir.'/'.$lock_name.'.lck', '');
}
/**
* forces rotation of the given log file
*
* @example symfony log-rotate
*
* @param object $task
* @param array $args
*/
function run_log_rotate($task, $args)
{
// handling two required arguments (application and environment)
if (count($args) < 2)
{
throw new Exception('You must provide the environment of the log to rotate');
}
$app = $args[0];
$env = $args[1];
// define constants
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
define('SF_APP', $app);
define('SF_ENVIRONMENT', $env);
define('SF_DEBUG', true);
// get configuration
require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
sfLogManager::rotate($app, $env, sfConfig::get('sf_logging_period'), sfConfig::get('sf_logging_history'), true);
}
/**
* purges the application log directory as per settings in logging.yml
*
* @example symfony log-purge
*
* @param object $task
* @param array $args
*/
function run_log_purge($task, $args)
{
$sf_symfony_data_dir = sfConfig::get('sf_symfony_data_dir');
$default_logging = sfYaml::load($sf_symfony_data_dir.'/config/logging.yml');
$app_dir = sfConfig::get('sf_app_dir');
$apps = pakeFinder::type('dir')->maxdepth(0)->relative()->ignore_version_control()->in('apps');
$ignore = array('all', 'default');
foreach ($apps as $app)
{
$logging = sfYaml::load($app_dir.'/'.$app.'/config/logging.yml');
$logging = array_merge($default_logging, $logging);
foreach ($logging as $env => $config)
{
if (in_array($env, $ignore))
{
continue;
}
$props = array_merge($default_logging['default'], is_array($config) ? $config : array());
$active = isset($props['active']) ? $props['active'] : true;
$purge = isset($props['purge']) ? $props['purge'] : true;
if ($active && $purge)
{
$filename = sfConfig::get('sf_log_dir').'/'.$app.'_'.$env.'.log';
if (file_exists($filename))
{
pake_remove($filename, '');
}
}
}
}
}
function run_enable($task, $args)
{
// handling two required arguments (application and environment)
if (count($args) < 2)
{
throw new Exception('You must provide an environment for the application.');
}
$app = $args[0];
$env = $args[1];
$lockFile = $app.'_'.$env.'.clilock';
$locks = pakeFinder::type('file')->prune('.svn')->discard('.svn')->maxdepth(0)->name($lockFile)->relative()->in('./');
if (file_exists(sfConfig::get('sf_root_dir').'/'.$lockFile))
{
pake_remove($lockFile, '');
run_clear_cache($task, array());
pake_echo_action('enable', "$app [$env] has been ENABLED");
return;
}
pake_echo_action('enable', "$app [$env] is currently ENABLED");
}
function run_disable($task, $args)
{
// handling two required arguments (application and environment)
if (count($args) < 2)
{
throw new Exception('You must provide an environment for the application.');
}
$app = $args[0];
$env = $args[1];
$lockFile = $app.'_'.$env.'.clilock';
if (!file_exists(sfConfig::get('sf_root_dir').'/'.$lockFile))
{
pake_touch(sfConfig::get('sf_root_dir').'/'.$lockFile, '777');
pake_echo_action('enable', "$app [$env] has been DISABLED");
return;
}
pake_echo_action('enable', "$app [$env] is currently DISABLED");
return;
}

View File

@ -0,0 +1,279 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('install a new plugin');
pake_task('plugin-install', 'project_exists');
pake_desc('upgrade a plugin');
pake_task('plugin-upgrade', 'project_exists');
pake_desc('uninstall a plugin');
pake_task('plugin-uninstall', 'project_exists');
pake_desc('list installed plugins');
pake_task('plugin-list', 'project_exists');
// symfony plugin-install pluginName
function run_plugin_install($task, $args)
{
if (!isset($args[0]))
{
throw new Exception('You must provide the plugin name.');
}
$config = _pear_init();
// install plugin
$packages = array($args[0]);
pake_echo_action('plugin', 'installing plugin "'.$args[0].'"');
list($ret, $error) = _pear_run_command($config, 'install', array(), $packages);
if ($error)
{
throw new Exception($error);
}
_install_web_content(_get_plugin_name($args[0]));
}
function run_plugin_upgrade($task, $args)
{
if (!isset($args[0]))
{
throw new Exception('You must provide the plugin name.');
}
$config = _pear_init();
// upgrade plugin
$packages = array($args[0]);
pake_echo_action('plugin', 'upgrading plugin "'.$args[0].'"');
list($ret, $error) = _pear_run_command($config, 'upgrade', array('loose' => true, 'nodeps' => true), $packages);
if ($error)
{
throw new Exception($error);
}
$plugin_name = _get_plugin_name($args[0]);
_uninstall_web_content($plugin_name);
_install_web_content($plugin_name);
}
function run_plugin_uninstall($task, $args)
{
if (!isset($args[0]))
{
throw new Exception('You must provide the plugin name.');
}
_uninstall_web_content(_get_plugin_name($args[0]));
$config = _pear_init();
// uninstall plugin
$packages = array($args[0]);
pake_echo_action('plugin', 'uninstalling plugin "'.$args[0].'"');
list($ret, $error) = _pear_run_command($config, 'uninstall', array(), $packages);
if ($error)
{
throw new Exception($error);
}
}
function run_plugin_list($task, $args)
{
pake_echo('Installed plugins:');
$config = _pear_init();
$registry = $config->getRegistry();
$installed = $registry->packageInfo(null, null, null);
foreach ($installed as $channel => $packages)
{
foreach ($packages as $package)
{
$pobj = $registry->getPackage(isset($package['package']) ? $package['package'] : $package['name'], $channel);
pake_echo(sprintf(" %-40s %10s-%-6s %s", pakeColor::colorize($pobj->getPackage(), 'INFO'), $pobj->getVersion(), $pobj->getState() ? $pobj->getState() : null, pakeColor::colorize(sprintf('# %s (%s)', $channel, $registry->getChannel($channel)->getAlias()), 'COMMENT')));
}
}
}
function _pear_run_command($config, $command, $opts, $params)
{
ob_start('_pear_echo_message', 2);
$cmd = PEAR_Command::factory($command, $config);
$ret = ob_get_clean();
if (PEAR::isError($cmd))
{
throw new Exception($cmd->getMessage());
}
ob_start('_pear_echo_message', 2);
$ok = $cmd->run($command, $opts, $params);
$ret .= ob_get_clean();
$ret = trim($ret);
return PEAR::isError($ok) ? array($ret, $ok->getMessage()) : array($ret, null);
}
function _pear_echo_message($message)
{
$t = '';
foreach (explode("\n", $message) as $longline)
{
foreach (explode("\n", wordwrap($longline, 62)) as $line)
{
if ($line = trim($line))
{
$t .= pake_format_action('pear', $line);
}
}
}
return $t;
}
function _pear_init()
{
require_once 'PEAR.php';
require_once 'PEAR/Frontend.php';
require_once 'PEAR/Config.php';
require_once 'PEAR/Registry.php';
require_once 'PEAR/Command.php';
require_once 'PEAR/Remote.php';
// current symfony release
$sf_version = preg_replace('/\-\w+$/', '', file_get_contents(sfConfig::get('sf_symfony_lib_dir').'/VERSION'));
// PEAR
PEAR_Command::setFrontendType('CLI');
$ui = &PEAR_Command::getFrontendObject();
// read user/system configuration (don't use the singleton)
$config = new PEAR_Config();
$config_file = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'.pearrc';
// change the configuration for symfony use
$config->set('php_dir', sfConfig::get('sf_plugins_dir'));
$config->set('data_dir', sfConfig::get('sf_plugins_dir'));
$config->set('test_dir', sfConfig::get('sf_plugins_dir'));
$config->set('doc_dir', sfConfig::get('sf_plugins_dir'));
$config->set('bin_dir', sfConfig::get('sf_plugins_dir'));
// change the PEAR temp dir
$config->set('cache_dir', sfConfig::get('sf_cache_dir'));
$config->set('download_dir', sfConfig::get('sf_cache_dir'));
$config->set('tmp_dir', sfConfig::get('sf_cache_dir'));
// save out configuration file
$config->writeConfigFile($config_file, 'user');
// use our configuration file
$config = &PEAR_Config::singleton($config_file);
$config->set('verbose', 1);
$ui->setConfig($config);
date_default_timezone_set('UTC');
// register our channel
$symfony_channel = array(
'attribs' => array(
'version' => '1.0',
'xmlns' => 'http://pear.php.net/channel-1.0',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://pear.php.net/dtd/channel-1.0 http://pear.php.net/dtd/channel-1.0.xsd',
),
'name' => 'pear.symfony-project.com',
'summary' => 'symfony project PEAR channel',
'suggestedalias' => 'symfony',
'servers' => array(
'primary' => array(
'rest' => array(
'baseurl' => array(
array(
'attribs' => array('type' => 'REST1.0'),
'_content' => 'http://pear.symfony-project.com/Chiara_PEAR_Server_REST/',
),
array(
'attribs' => array('type' => 'REST1.1'),
'_content' => 'http://pear.symfony-project.com/Chiara_PEAR_Server_REST/',
),
),
),
),
),
'_lastmodified' => array(
'ETag' => "113845-297-dc93f000",
'Last-Modified' => date('r'),
),
);
pake_mkdirs(sfConfig::get('sf_plugins_dir').'/.channels/.alias');
file_put_contents(sfConfig::get('sf_plugins_dir').'/.channels/pear.symfony-project.com.reg', serialize($symfony_channel));
file_put_contents(sfConfig::get('sf_plugins_dir').'/.channels/.alias/symfony.txt', 'pear.symfony-project.com');
// register symfony for dependencies
$symfony = array(
'name' => 'symfony',
'channel' => 'pear.symfony-project.com',
'date' => date('Y-m-d'),
'time' => date('H:i:s'),
'version' => array('release' => $sf_version, 'api' => '1.0.0'),
'stability' => array('release' => 'stable', 'api' => 'stable'),
'xsdversion' => '2.0',
'_lastmodified' => time(),
'old' => array('version' => $sf_version, 'release_state' => 'stable'),
);
$dir = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'.registry'.DIRECTORY_SEPARATOR.'.channel.pear.symfony-project.com';
pake_mkdirs($dir);
file_put_contents($dir.DIRECTORY_SEPARATOR.'symfony.reg', serialize($symfony));
return $config;
}
function _get_plugin_name($arg)
{
$plugin_name = (false !== $pos = strrpos($arg, '/')) ? substr($arg, $pos + 1) : $arg;
$plugin_name = (false !== $pos = strrpos($plugin_name, '-')) ? substr($plugin_name, 0, $pos) : $plugin_name;
return $plugin_name;
}
function _install_web_content($plugin_name)
{
$web_dir = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$plugin_name.DIRECTORY_SEPARATOR.'web';
if (is_dir($web_dir))
{
pake_echo_action('plugin', 'installing web data for plugin');
pake_symlink($web_dir, sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$plugin_name, true);
}
}
function _uninstall_web_content($plugin_name)
{
$web_dir = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$plugin_name.DIRECTORY_SEPARATOR.'web';
$target_dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$plugin_name;
if (is_dir($web_dir) && is_dir($target_dir))
{
pake_echo_action('plugin', 'uninstalling web data for plugin');
if (is_link($target_dir))
{
pake_remove($target_dir, '');
}
else
{
pake_remove(pakeFinder::type('any'), $target_dir);
pake_remove($target_dir, '');
}
}
}

View File

@ -0,0 +1,383 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('create classes for current model');
pake_task('propel-build-model', 'project_exists');
pake_desc('create sql for current model');
pake_task('propel-build-sql', 'project_exists');
pake_desc('create schema.xml from existing database');
pake_task('propel-build-schema', 'project_exists');
pake_desc('create schema.xml from schema.yml');
pake_task('propel-convert-yml-schema', 'project_exists');
pake_desc('create schema.yml from schema.xml');
pake_task('propel-convert-xml-schema', 'project_exists');
pake_desc('load data from fixtures directory');
pake_task('propel-load-data', 'project_exists');
pake_desc('dump data to fixtures directory');
pake_task('propel-dump-data', 'project_exists');
pake_desc('create database for current model');
pake_task('propel-build-db', 'project_exists');
pake_desc('insert sql for current model');
pake_task('propel-insert-sql', 'project_exists');
pake_desc('generate propel model and sql and initialize database');
pake_task('propel-build-all', 'project_exists');
pake_desc('generate propel model and sql and initialize database, and load data');
pake_task('propel-build-all-load', 'propel-build-all');
function run_propel_convert_yml_schema($task, $args)
{
_propel_convert_yml_schema(true);
}
function run_propel_convert_xml_schema($task, $args)
{
_propel_convert_xml_schema(true);
}
function _propel_convert_yml_schema($check_schema = true, $prefix = '')
{
$finder = pakeFinder::type('file')->name('*schema.yml');
$dirs = array('config');
if ($pluginDirs = glob(sfConfig::get('sf_root_dir').'/plugins/*/config'))
{
$dirs = array_merge($dirs, $pluginDirs);
}
$schemas = $finder->in($dirs);
if ($check_schema && !count($schemas))
{
throw new Exception('You must create a schema.yml file.');
}
$db_schema = new sfPropelDatabaseSchema();
foreach ($schemas as $schema)
{
$db_schema->loadYAML($schema);
pake_echo_action('schema', 'converting "'.$schema.'"'.' to XML');
$localprefix = $prefix;
// change prefix for plugins
if (preg_match('#plugins[/\\\\]([^/\\\\]+)[/\\\\]#', $schema, $match))
{
$localprefix = $prefix.$match[1].'-';
}
// save converted xml files in original directories
$xml_file_name = str_replace('.yml', '.xml', basename($schema));
$file = str_replace(basename($schema), $localprefix.$xml_file_name, $schema);
pake_echo_action('schema', 'putting '.$file);
file_put_contents($file, $db_schema->asXML());
}
}
function _propel_convert_xml_schema($check_schema = true, $prefix = '')
{
$finder = pakeFinder::type('file')->name('*schema.xml');
$schemas = array_merge($finder->in('config'), $finder->in(glob(sfConfig::get('sf_root_dir').'/plugins/*/config')));
if ($check_schema && !count($schemas))
{
throw new Exception('You must create a schema.xml file.');
}
$db_schema = new sfPropelDatabaseSchema();
foreach ($schemas as $schema)
{
$db_schema->loadXML($schema);
$localprefix = $prefix;
// change prefix for plugins
if (preg_match('#plugins[/\\\\]([^/\\\\]+)[/\\\\]#', $schema, $match))
{
$localprefix = $prefix.$match[1].'-';
}
// save converted xml files in original directories
$yml_file_name = str_replace('.xml', '.yml', basename($schema));
$file = str_replace(basename($schema), $prefix.$yml_file_name, $schema);
pake_echo_action('schema', 'putting '.$file);
file_put_contents($file, $db_schema->asYAML());
}
}
function _propel_copy_xml_schema_from_plugins($prefix = '')
{
$schemas = pakeFinder::type('file')->name('*schema.xml')->in(glob(sfConfig::get('sf_root_dir').'/plugins/*/config'));
foreach ($schemas as $schema)
{
// reset local prefix
$localprefix = '';
// change prefix for plugins
if (preg_match('#plugins[/\\\\]([^/\\\\]+)[/\\\\]#', $schema, $match))
{
// if the plugin name is not in the schema filename, add it
if (!strstr(basename($schema), $match[1]))
{
$localprefix = $match[1].'-';
}
}
// if the prefix is not in the schema filename, add it
if (!strstr(basename($schema), $prefix))
{
$localprefix = $prefix.$localprefix;
}
pake_copy($schema, 'config'.DIRECTORY_SEPARATOR.$localprefix.basename($schema));
if ('' === $localprefix)
{
pake_remove($schema, '');
}
}
}
function run_propel_build_all($task, $args)
{
run_propel_build_model($task, $args);
run_propel_build_sql($task, $args);
run_propel_insert_sql($task, $args);
}
function run_propel_build_all_load($task, $args)
{
run_propel_build_all($task, $args);
run_propel_load_data($task, $args);
}
function run_propel_build_model($task, $args)
{
_propel_convert_yml_schema(false, 'generated-');
_propel_copy_xml_schema_from_plugins('generated-');
_call_phing($task, 'om');
$finder = pakeFinder::type('file')->name('generated-*schema.xml');
pake_remove($finder, array('config', 'plugins'));
}
function run_propel_build_sql($task, $args)
{
_propel_convert_yml_schema(false, 'generated-');
_propel_copy_xml_schema_from_plugins('generated-');
_call_phing($task, 'sql');
$finder = pakeFinder::type('file')->name('generated-*schema.xml');
pake_remove($finder, 'config');
}
function run_propel_build_db($task, $args)
{
_call_phing($task, 'create-db', false);
}
function run_propel_insert_sql($task, $args)
{
_propel_convert_yml_schema(false, 'generated-');
_propel_copy_xml_schema_from_plugins('generated-');
_call_phing($task, 'insert-sql');
$finder = pakeFinder::type('file')->name('generated-*schema.xml');
pake_remove($finder, 'config');
}
function run_propel_build_schema($task, $args)
{
_call_phing($task, 'creole', false);
// fix database name
if (file_exists('config/schema.xml'))
{
$schema = file_get_contents('config/schema.xml');
$schema = preg_replace('/<database\s+name="[^"]+"/s', '<database name="propel"', $schema);
file_put_contents('config/schema.xml', $schema);
}
if (!isset($args[0]) || $args[0] != 'xml')
{
_propel_convert_xml_schema(false, '');
$finder = pakeFinder::type('file')->name('schema.xml');
pake_remove($finder, 'config');
}
}
/**
* Dumps yml database data to fixtures directory.
*
* @example symfony dump-data frontend data.yml
* @example symfony dump-data frontend data.yml dev
*
* @param object $task
* @param array $args
*/
function run_propel_dump_data($task, $args)
{
if (!count($args))
{
throw new Exception('You must provide the app.');
}
$app = $args[0];
if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app))
{
throw new Exception('The app "'.$app.'" does not exist.');
}
if (!isset($args[1]))
{
throw new Exception('You must provide a filename.');
}
$filename = $args[1];
$env = empty($args[2]) ? 'dev' : $args[2];
// define constants
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
define('SF_APP', $app);
define('SF_ENVIRONMENT', $env);
define('SF_DEBUG', true);
// get configuration
require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
if (!sfToolkit::isPathAbsolute($filename))
{
$dir = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures';
pake_mkdirs($dir);
$filename = $dir.DIRECTORY_SEPARATOR.$filename;
}
pake_echo_action('propel', sprintf('dumping data to "%s"', $filename));
$data = new sfPropelData();
$data->dumpData($filename);
}
/**
* Loads yml data from fixtures directory and inserts into database.
*
* @example symfony load-data frontend
* @example symfony load-data frontend dev fixtures append
*
* @todo replace delete argument with flag -d
*
* @param object $task
* @param array $args
*/
function run_propel_load_data($task, $args)
{
if (!count($args))
{
throw new Exception('You must provide the app.');
}
$app = $args[0];
if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app))
{
throw new Exception('The app "'.$app.'" does not exist.');
}
if (count($args) > 1 && $args[count($args) - 1] == 'append')
{
array_pop($args);
$delete = false;
}
else
{
$delete = true;
}
$env = empty($args[1]) ? 'dev' : $args[1];
// define constants
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
define('SF_APP', $app);
define('SF_ENVIRONMENT', $env);
define('SF_DEBUG', true);
// get configuration
require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
if (count($args) == 1)
{
if (!$pluginDirs = glob(sfConfig::get('sf_root_dir').'/plugins/*/data'))
{
$pluginDirs = array();
}
$fixtures_dirs = pakeFinder::type('dir')->name('fixtures')->in(array_merge($pluginDirs, array(sfConfig::get('sf_data_dir'))));
}
else
{
$fixtures_dirs = array_slice($args, 1);
}
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$data = new sfPropelData();
$data->setDeleteCurrentData($delete);
foreach ($fixtures_dirs as $fixtures_dir)
{
if (!is_readable($fixtures_dir))
{
continue;
}
pake_echo_action('propel', sprintf('load data from "%s"', $fixtures_dir));
$data->loadData($fixtures_dir);
}
}
function _call_phing($task, $task_name, $check_schema = true)
{
$schemas = pakeFinder::type('file')->name('*schema.xml')->relative()->follow_link()->in('config');
if ($check_schema && !$schemas)
{
throw new Exception('You must create a schema.yml or schema.xml file.');
}
// call phing targets
pake_import('Phing', false);
if (false === strpos('propel-generator', get_include_path()))
{
set_include_path(sfConfig::get('sf_symfony_lib_dir').'/vendor/propel-generator/classes'.PATH_SEPARATOR.get_include_path());
}
set_include_path(sfConfig::get('sf_root_dir').PATH_SEPARATOR.get_include_path());
// needed to include the right Propel builders
set_include_path(sfConfig::get('sf_symfony_lib_dir').PATH_SEPARATOR.get_include_path());
$options = array(
'project.dir' => sfConfig::get('sf_root_dir').'/config',
'build.properties' => 'propel.ini',
'propel.output.dir' => sfConfig::get('sf_root_dir'),
);
pakePhingTask::call_phing($task, array($task_name), sfConfig::get('sf_symfony_lib_dir').'/vendor/propel-generator/build.xml', $options);
chdir(sfConfig::get('sf_root_dir'));
}

View File

@ -0,0 +1,66 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('initialize a new propel admin module');
pake_task('propel-init-admin', 'app_exists');
function run_propel_init_admin($task, $args)
{
if (count($args) < 2)
{
throw new Exception('You must provide your module name.');
}
if (count($args) < 3)
{
throw new Exception('You must provide your model class name.');
}
$app = $args[0];
$module = $args[1];
$model_class = $args[2];
$theme = isset($args[3]) ? $args[3] : 'default';
try
{
$author_name = $task->get_property('author', 'symfony');
}
catch (pakeException $e)
{
$author_name = 'Your name here';
}
$constants = array(
'PROJECT_NAME' => $task->get_property('name', 'symfony'),
'APP_NAME' => $app,
'MODULE_NAME' => $module,
'MODEL_CLASS' => $model_class,
'AUTHOR_NAME' => $author_name,
'THEME' => $theme,
);
$moduleDir = sfConfig::get('sf_root_dir').'/'.sfConfig::get('sf_apps_dir_name').'/'.$app.'/'.sfConfig::get('sf_app_module_dir_name').'/'.$module;
// create module structure
$finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf');
$dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelAdmin', $theme);
foreach ($dirs as $dir)
{
if (is_dir($dir))
{
pake_mirror($finder, $dir, $moduleDir);
break;
}
}
// customize php and yml files
$finder = pakeFinder::type('file')->name('*.php', '*.yml');
pake_replace_tokens($finder, $moduleDir, '##', '##', $constants);
}

View File

@ -0,0 +1,134 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('initialize a new propel CRUD module');
pake_task('propel-init-crud', 'app_exists');
pake_desc('generate a new propel CRUD module');
pake_task('propel-generate-crud', 'app_exists');
function run_propel_init_crud($task, $args)
{
if (count($args) < 2)
{
throw new Exception('You must provide your module name.');
}
if (count($args) < 3)
{
throw new Exception('You must provide your model class name.');
}
$app = $args[0];
$module = $args[1];
$model_class = $args[2];
try
{
$author_name = $task->get_property('author', 'symfony');
}
catch (pakeException $e)
{
$author_name = 'Your name here';
}
$constants = array(
'PROJECT_NAME' => $task->get_property('name', 'symfony'),
'APP_NAME' => $app,
'MODULE_NAME' => $module,
'MODEL_CLASS' => $model_class,
'AUTHOR_NAME' => $author_name,
);
$sf_root_dir = sfConfig::get('sf_root_dir');
$moduleDir = $sf_root_dir.'/'.sfConfig::get('sf_apps_dir_name').'/'.$app.'/'.sfConfig::get('sf_app_module_dir_name').'/'.$module;
// create basic application structure
$finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf');
pake_mirror($finder, sfConfig::get('sf_symfony_data_dir').'/generator/sfPropelCrud/default/skeleton', $moduleDir);
// create basic test
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/module/test/actionsTest.php', $sf_root_dir.'/test/functional/'.$app.'/'.$module.'ActionsTest.php');
// customize test file
pake_replace_tokens($module.'ActionsTest.php', $sf_root_dir.'/test/functional/'.$app, '##', '##', $constants);
// customize php and yml files
$finder = pakeFinder::type('file')->name('*.php', '*.yml');
pake_replace_tokens($finder, $moduleDir, '##', '##', $constants);
}
function run_propel_generate_crud($task, $args)
{
if (count($args) < 2)
{
throw new Exception('You must provide your module name.');
}
if (count($args) < 3)
{
throw new Exception('You must provide your model class name.');
}
$theme = isset($args[3]) ? $args[3] : 'default';
$app = $args[0];
$module = $args[1];
$model_class = $args[2];
$sf_root_dir = sfConfig::get('sf_root_dir');
// generate module
$tmp_dir = $sf_root_dir.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true));
sfConfig::set('sf_module_cache_dir', $tmp_dir);
$generator_manager = new sfGeneratorManager();
$generator_manager->initialize();
$generator_manager->generate('sfPropelCrudGenerator', array('model_class' => $model_class, 'moduleName' => $module, 'theme' => $theme));
$moduleDir = $sf_root_dir.'/'.sfConfig::get('sf_apps_dir_name').'/'.$app.'/'.sfConfig::get('sf_app_module_dir_name').'/'.$module;
// copy our generated module
$finder = pakeFinder::type('any');
pake_mirror($finder, $tmp_dir.'/auto'.ucfirst($module), $moduleDir);
// change module name
pake_replace_tokens($moduleDir.'/actions/actions.class.php', getcwd(), '', '', array('auto'.ucfirst($module) => $module));
try
{
$author_name = $task->get_property('author', 'symfony');
}
catch (pakeException $e)
{
$author_name = 'Your name here';
}
$constants = array(
'PROJECT_NAME' => $task->get_property('name', 'symfony'),
'APP_NAME' => $app,
'MODULE_NAME' => $module,
'MODEL_CLASS' => $model_class,
'AUTHOR_NAME' => $author_name,
);
// customize php and yml files
$finder = pakeFinder::type('file')->name('*.php', '*.yml');
pake_replace_tokens($finder, $moduleDir, '##', '##', $constants);
// create basic test
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/module/test/actionsTest.php', $sf_root_dir.'/test/functional/'.$app.'/'.$module.'ActionsTest.php');
// customize test file
pake_replace_tokens($module.'ActionsTest.php', $sf_root_dir.'/test/functional/'.$app, '##', '##', $constants);
// delete temp files
$finder = pakeFinder::type('any');
pake_remove($finder, $tmp_dir);
}

View File

@ -0,0 +1,90 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('freeze symfony libraries');
pake_task('freeze', 'project_exists');
pake_desc('unfreeze symfony libraries');
pake_task('unfreeze', 'project_exists');
function run_freeze($task, $args)
{
// check that the symfony librairies are not already freeze for this project
if (is_readable('lib/symfony'))
{
throw new Exception('You can only freeze when lib/symfony is empty.');
}
if (is_readable('data/symfony'))
{
throw new Exception('You can only freeze when data/symfony is empty.');
}
if (is_readable('web/sf'))
{
throw new Exception('You can only freeze when web/sf is empty.');
}
if (is_link('web/sf'))
{
pake_remove('web/sf', '');
}
$symfony_lib_dir = sfConfig::get('sf_symfony_lib_dir');
$symfony_data_dir = sfConfig::get('sf_symfony_data_dir');
pake_echo_action('freeze', 'freezing lib found in "'.$symfony_lib_dir.'"');
pake_echo_action('freeze', 'freezing data found in "'.$symfony_data_dir.'"');
pake_mkdirs('lib'.DIRECTORY_SEPARATOR.'symfony');
pake_mkdirs('data'.DIRECTORY_SEPARATOR.'symfony');
$finder = pakeFinder::type('any')->ignore_version_control();
pake_mirror($finder, $symfony_lib_dir, 'lib/symfony');
pake_mirror($finder, $symfony_data_dir, 'data/symfony');
pake_rename('data/symfony/web/sf', 'web/sf');
// change symfony paths in config/config.php
file_put_contents('config/config.php.bak', "$symfony_lib_dir#$symfony_data_dir");
_change_symfony_dirs("dirname(__FILE__).'/../lib/symfony'", "dirname(__FILE__).'/../data/symfony'");
// install the command line
pake_copy($symfony_data_dir.'/bin/symfony.php', 'symfony.php');
}
function run_unfreeze($task, $args)
{
// remove lib/symfony and data/symfony directories
if (!is_dir('lib/symfony'))
{
throw new Exception('You can unfreeze only if you froze the symfony libraries before.');
}
$dirs = explode('#', file_get_contents('config/config.php.bak'));
_change_symfony_dirs('\''.$dirs[0].'\'', '\''.$dirs[1].'\'');
$finder = pakeFinder::type('any');
pake_remove($finder, 'lib/symfony');
pake_remove('lib/symfony', '');
pake_remove($finder, 'data/symfony');
pake_remove('data/symfony', '');
pake_remove('symfony.php', '');
pake_remove($finder, 'web/sf');
pake_remove('web/sf', '');
}
function _change_symfony_dirs($symfony_lib_dir, $symfony_data_dir)
{
$content = file_get_contents('config/config.php');
$content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content);
$content = preg_replace("/^(\s*.sf_symfony_data_dir\s*=\s*).+?;/m", "$1$symfony_data_dir;", $content);
file_put_contents('config/config.php', $content);
}

100
data/symfony/tasks/sfPakeTest.php Executable file
View File

@ -0,0 +1,100 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('launch unit tests');
pake_task('test-unit', 'project_exists');
pake_desc('launch functional tests for an application');
pake_task('test-functional', 'project_exists');
pake_desc('launch all tests');
pake_task('test-all', 'project_exists');
function run_test_all($task, $args)
{
require_once(sfConfig::get('sf_symfony_lib_dir').'/vendor/lime/lime.php');
$h = new lime_harness(new lime_output_color());
$h->base_dir = sfConfig::get('sf_test_dir');
// register all tests
$finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
$h->register($finder->in($h->base_dir));
$h->run();
}
function run_test_functional($task, $args)
{
if (!count($args))
{
throw new Exception('You must provide the app to test.');
}
$app = $args[0];
if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app))
{
throw new Exception(sprintf('The app "%s" does not exist.', $app));
}
if (isset($args[1]))
{
foreach (array_splice($args, 1) as $path)
{
$files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.dirname($path));
foreach ($files as $file)
{
include($file);
}
}
}
else
{
require_once(sfConfig::get('sf_symfony_lib_dir').'/vendor/lime/lime.php');
$h = new lime_harness(new lime_output_color());
$h->base_dir = sfConfig::get('sf_test_dir').'/functional/'.$app;
// register functional tests
$finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
$h->register($finder->in($h->base_dir));
$h->run();
}
}
function run_test_unit($task, $args)
{
if (isset($args[0]))
{
foreach ($args as $path)
{
$files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'unit'.DIRECTORY_SEPARATOR.dirname($path));
foreach ($files as $file)
{
include($file);
}
}
}
else
{
require_once(sfConfig::get('sf_symfony_lib_dir').'/vendor/lime/lime.php');
$h = new lime_harness(new lime_output_color());
$h->base_dir = sfConfig::get('sf_test_dir').'/unit';
// register unit tests
$finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
$h->register($finder->in($h->base_dir));
$h->run();
}
}

View File

@ -0,0 +1,777 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
pake_desc('upgrade to a new symfony release');
pake_task('upgrade');
pake_desc('downgrade to a previous symfony release');
pake_task('downgrade', 'project_exists');
function run_downgrade($task, $args)
{
throw new Exception('I have no downgrade script for this release.');
}
function run_upgrade($task, $args)
{
if (!isset($args[0]))
{
throw new Exception('You must provide the upgrade script to use (1.0 to upgrade to symfony 1.0 for example).');
}
$version = $args[0];
if ($version == '1.0')
{
run_upgrade_1_0($task, $args);
}
else
{
throw new Exception('I have no upgrade script for this release.');
}
}
function run_upgrade_1_0($task, $args)
{
// check we have a project
if (!file_exists('symfony') && !file_exists('SYMFONY'))
{
throw new Exception('You must be in a symfony project directory');
}
// upgrade propel.ini
_upgrade_1_0_propel_ini();
// upgrade i18n support
_upgrade_1_0_i18n();
// upgrade model classes
_upgrade_1_0_propel_model();
// migrate activate to enabled
_upgrade_1_0_activate();
// find all applications for this project
$apps = pakeFinder::type('directory')->name(sfConfig::get('sf_app_module_dir_name'))->mindepth(1)->maxdepth(1)->relative()->in(sfConfig::get('sf_apps_dir_name'));
// install symfony CLI
if (file_exists(sfConfig::get('sf_root_dir').'/SYMFONY'))
{
pake_remove(sfConfig::get('sf_root_dir').'/SYMFONY', '');
}
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/project/symfony', sfConfig::get('sf_root_dir').'/symfony');
pake_chmod('symfony', sfConfig::get('sf_root_dir'), 0777);
// update schemas
_upgrade_1_0_schemas();
// add bootstrap files for tests
_add_1_0_test_bootstraps();
// upgrade main config.php
_upgrade_1_0_main_config_php();
// upgrade all applications
foreach ($apps as $app_module_dir)
{
$app = str_replace(DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_dir_name'), '', $app_module_dir);
pake_echo_action('upgrade 1.0', pakeColor::colorize(sprintf('upgrading application "%s"', $app), array('fg' => 'cyan')));
$app_dir = sfConfig::get('sf_apps_dir_name').'/'.$app;
// upgrade config.php
_upgrade_1_0_config_php($app_dir);
// upgrade filters.yml
_upgrade_1_0_filters_yml($app_dir);
// upgrade all modules
$dir = $app_dir.'/'.sfConfig::get('sf_app_module_dir_name');
if ($dir)
{
// template dirs
$template_dirs = pakeFinder::type('directory')->name('templates')->mindepth(1)->maxdepth(1)->in($dir);
$template_dirs[] = $app_dir.'/'.sfConfig::get('sf_app_template_dir_name');
_upgrade_1_0_deprecated_for_templates($template_dirs);
_upgrade_1_0_date_form_helpers($template_dirs);
_upgrade_1_0_deprecated_for_generator($app_dir);
_upgrade_1_0_cache_yml($app_dir);
// actions dirs
$action_dirs = pakeFinder::type('directory')->name('actions')->mindepth(1)->maxdepth(1)->in($dir);
_upgrade_1_0_deprecated_for_actions($action_dirs);
// view.yml
_upgrade_1_0_view_yml($app_dir);
_upgrade_1_0_php_files($app_dir);
}
}
pake_echo_action('upgrade 1.0', 'done');
pake_mkdirs(sfConfig::get('sf_root_dir').'/plugins');
if (is_dir(sfConfig::get('sf_lib_dir').'/plugins'))
{
pake_echo_comment('WARNING: you must re-install all your plugins');
}
pake_echo_comment('Now, you must:');
pake_echo_comment(' - rebuild your model classes: symfony propel-build-model');
pake_echo_comment(' - clear the cache: symfony cc');
}
function _upgrade_1_0_i18n()
{
$dirs = array(sfConfig::get('sf_lib_dir_name'), sfConfig::get('sf_apps_dir_name'));
$finder = pakeFinder::type('file')->name('*.php');
$seen = false;
foreach ($finder->in($dirs) as $php_file)
{
$content = file_get_contents($php_file);
$count = 0;
$content = str_replace('sfConfig::get(\'sf_i18n_instance\')', 'sfContext::getInstance()->getI18N()', $content, $count);
if ($count && !$seen)
{
$seen = true;
pake_echo_comment('sfConfig::get(\'sf_i18n_instance\') is deprecated');
pake_echo_comment(' use sfContext::getInstance()->getI18N()');
}
if ($count)
{
file_put_contents($php_file, $content);
}
}
}
function _upgrade_1_0_php_files($app_dir)
{
pake_echo_action('upgrade 1.0', 'upgrading sf/ path configuration');
$php_files = pakeFinder::type('file')->name('*.php')->in($app_dir);
foreach ($php_files as $php_file)
{
$content = file_get_contents($php_file);
$deprecated = array(
"'/sf/js/prototype" => "sfConfig::get('sf_prototype_web_dir').'/js",
"'/sf/css/prototype" => "sfConfig::get('sf_prototype_web_dir').'/css",
"'/sf/js/sf_admin" => "sfConfig::get('sf_admin_web_dir').'/js",
"'/sf/css/sf_admin" => "sfConfig::get('sf_admin_web_dir').'/css",
"'/sf/images/sf_admin" => "sfConfig::get('sf_admin_web_dir').'/images",
);
$seen = array();
$updated = false;
foreach ($deprecated as $old => $new)
{
$count = 0;
$content = str_replace($old, $new, $content, $count);
if ($count)
{
$updated = true;
}
if ($count && !isset($seen[$old]))
{
$seen[$old] = true;
pake_echo_comment(sprintf('%s is deprecated', $old));
pake_echo_comment(sprintf(' use %s', $new));
}
}
if ($updated)
{
file_put_contents($php_file, $content);
}
}
}
function _upgrade_1_0_activate()
{
pake_echo_action('upgrade 1.0', 'migrate activate to enabled');
$config_files = array(
'settings.yml' => array(
'activated_modules:' => 'enabled_modules: ',
),
'cache.yml' => array(
'activate:' => 'enabled: ',
),
'logging.yml' => array(
'active:' => 'enabled:',
),
'*.php' => array(
'sf_logging_'.'active' => 'sf_logging_enabled',
),
'apps/*/modules/*/validate/*.yml' => array(
'activate:' => 'enabled: ',
),
);
$seen = array();
foreach ($config_files as $config_file => $changed)
{
list($dir, $config_file) = array(dirname($config_file), basename($config_file));
$files = pakeFinder::type('file')->name($config_file)->in(sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.$dir);
foreach ($files as $file)
{
$content = file_get_contents($file);
$updated = false;
foreach ($changed as $old => $new)
{
$content = str_replace($old, $new, $content, $count);
if ($count)
{
$updated = true;
}
if ($count && !isset($seen[$config_file.$old]))
{
$seen[$config_file.$old] = true;
pake_echo_comment(sprintf('%s is deprecated in %s', $old, $config_file));
pake_echo_comment(sprintf(' use %s', $new));
}
}
if ($updated)
{
file_put_contents($file, $content);
}
}
}
}
function _upgrade_1_0_view_yml($app_dir)
{
pake_echo_action('upgrade 1.0', 'upgrading view configuration');
$yml_files = pakeFinder::type('file')->name('*.yml')->in($app_dir);
foreach ($yml_files as $yml_file)
{
$content = file_get_contents($yml_file);
$deprecated = array(
'/sf/js/prototype' => '%SF_PROTOTYPE_WEB_DIR%/js',
'/sf/css/prototype' => '%SF_PROTOTYPE_WEB_DIR%/css',
'/sf/js/sf_admin' => '%SF_ADMIN_WEB_DIR%/js',
'/sf/css/sf_admin' => '%SF_ADMIN_WEB_DIR%/css',
'/sf/images/sf_admin' => '%SF_ADMIN_WEB_DIR%/images',
);
$seen = array();
$updated = false;
foreach ($deprecated as $old => $new)
{
$count = 0;
$content = str_replace($old, $new, $content, $count);
if ($count)
{
$updated = true;
}
if ($count && !isset($seen[$old]))
{
$seen[$old] = true;
pake_echo_comment(sprintf('%s is deprecated', $old));
pake_echo_comment(sprintf(' use %s', $new));
}
}
if ($updated)
{
file_put_contents($yml_file, $content);
}
}
}
function _upgrade_1_0_cache_yml($app_dir)
{
pake_echo_action('upgrade 1.0', 'upgrading cache configuration');
$yml_files = pakeFinder::type('files')->name('cache.yml')->in($app_dir);
$seen = false;
foreach ($yml_files as $yml_file)
{
$content = file_get_contents($yml_file);
$count = 0;
$updated = false;
$content = preg_replace_callback('/type\:(\s*)(.+)$/m', '_upgrade_1_0_cache_yml_callback', $content, -1, $count);
if ($count)
{
$updated = true;
}
if ($count && !$seen)
{
$seen = true;
pake_echo_comment('"type" has been removed in cache.yml');
pake_echo_comment(' read the doc about "with_layout"');
}
if ($updated)
{
file_put_contents($yml_file, $content);
}
}
}
function _upgrade_1_0_cache_yml_callback($match)
{
return 'with_layout:'.str_repeat(' ', max(1, strlen($match[1]) - 6)).(0 === strpos($match[2], 'page') ? 'true' : 'false');
}
function _upgrade_1_0_deprecated_for_generator($app_dir)
{
pake_echo_action('upgrade 1.0', 'upgrading deprecated helpers in generator.yml');
$yml_files = pakeFinder::type('files')->name('generator.yml')->in($app_dir);
$seen = array();
$deprecated_str = array(
'admin_input_upload_tag' => 'admin_input_file_tag',
);
foreach ($yml_files as $yml_file)
{
$updated = false;
foreach ($deprecated_str as $old => $new)
{
$content = file_get_contents($yml_file);
$count = 0;
$content = str_replace($old, $new, $content, $count);
if ($count)
{
$updated = true;
}
if ($count && !isset($seen[$old]))
{
$seen[$old] = true;
pake_echo_comment(sprintf('%s() has been removed', $old));
pake_echo_comment(sprintf(' use %s()', $new));
}
}
if ($updated)
{
file_put_contents($yml_file, $content);
}
}
}
function _upgrade_1_0_deprecated_for_actions($action_dirs)
{
pake_echo_action('upgrade 1.0', 'upgrading deprecated methods in actions');
$php_files = pakeFinder::type('file')->name('*.php')->in($action_dirs);
foreach ($php_files as $php_file)
{
$content = file_get_contents($php_file);
$deprecated = array(
'$this->addHttpMeta' => '$this->getContext()->getResponse()->addHttpMeta',
'$this->addMeta' => '$this->getContext()->getResponse()->addMeta',
'$this->setTitle' => '$this->getContext()->getResponse()->setTitle',
'$this->addStylesheet' => '$this->getContext()->getResponse()->addStylesheet',
'$this->addJavascript' => '$this->getContext()->getResponse()->addJavascript',
);
$seen = array();
$updated = false;
foreach ($deprecated as $old => $new)
{
$count = 0;
$content = str_replace($old, $new, $content, $count);
if ($count)
{
$updated = true;
}
if ($count && !isset($seen[$old]))
{
$seen[$old] = true;
pake_echo_comment(sprintf('%s has been removed', $old));
pake_echo_comment(sprintf(' use %s', $new));
}
}
if ($updated)
{
file_put_contents($php_file, $content);
}
}
}
function _upgrade_1_0_date_form_helpers($template_dirs)
{
pake_echo_action('upgrade 1.0', 'upgrading date form helpers');
$helpers = array(
'select_day_tag', 'select_month_tag', 'select_year_tag', 'select_date_tag', 'select_second_tag', 'select_minute_tag',
'select_hour_tag', 'select_ampm_tag', 'select_time_tag', 'select_datetime_tag', 'select_number_tag', 'select_timezone_tag',
);
$regex = '/('.implode('|', $helpers).')/';
$php_files = pakeFinder::type('file')->name('*.php')->in($template_dirs);
$seen = false;
foreach ($php_files as $php_file)
{
$updated = false;
$content = file_get_contents($php_file);
if (preg_match($regex, $content) && false === strpos($content, 'DateForm'))
{
$content = "<?php use_helper('DateForm') ?>\n\n".$content;
$updated = true;
if (!$seen)
{
$seen = true;
pake_echo_comment('date form helpers has been moved to the DateForm helper group');
pake_echo_comment(' add use_helper(\'DateForm\')');
}
}
if ($updated)
{
file_put_contents($php_file, $content);
}
}
}
function _upgrade_1_0_deprecated_for_templates($template_dirs)
{
pake_echo_action('upgrade 1.0', 'upgrading deprecated helpers');
$php_files = pakeFinder::type('file')->name('*.php')->in($template_dirs);
$seen = array();
$deprecated_str = array(
'use_helpers' => 'use_helper',
'object_admin_input_upload_tag' => 'object_admin_input_file_tag',
'input_upload_tag' => 'input_file_tag',
'$sf_last_module' => '$sf_context->getModuleName()',
'$sf_last_action' => '$sf_context->getActionName()',
'$sf_first_module' => '$sf_context->getActionStack()->getFirstEntry()->getModuleName()',
'$sf_first_action' => '$sf_context->getActionStack()->getFirstEntry()->getActionName()',
);
foreach ($php_files as $php_file)
{
$content = file_get_contents($php_file);
$updated = false;
$count = 0;
foreach ($deprecated_str as $old => $new)
{
$content = str_replace($old, $new, $content, $count);
if ($count)
{
$updated = true;
}
if ($count && !isset($seen[$old]))
{
$seen[$old] = true;
pake_echo_comment(sprintf('%s has been removed', $old));
pake_echo_comment(sprintf(' use %s', $new));
}
}
if ($updated)
{
file_put_contents($php_file, $content);
}
}
}
function _upgrade_1_0_config_php($app_dir)
{
pake_echo_action('upgrade 1.0', 'upgrading config.php');
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/app/app/config/config.php', $app_dir.DIRECTORY_SEPARATOR.sfConfig::get('sf_config_dir_name').DIRECTORY_SEPARATOR.'config.php');
}
function _upgrade_1_0_filters_yml($app_dir)
{
pake_echo_action('upgrade 1.0', 'upgrading filters.yml');
$configFile = $app_dir.DIRECTORY_SEPARATOR.sfConfig::get('sf_config_dir_name').DIRECTORY_SEPARATOR.'filters.yml';
$content = file_get_contents($configFile);
// default symfony filters
$default = file_get_contents(sfConfig::get('sf_symfony_data_dir').'/skeleton/app/app/config/filters.yml');
$placeholder = '# generally, you will want to insert your own filters here';
// upgrade module filters.yml
$seen = false;
$yml_files = pakeFinder::type('file')->name('filters.yml')->in($app_dir.DIRECTORY_SEPARATOR.'modules');
foreach ($yml_files as $yml_file)
{
$module_content = file_get_contents($yml_file);
if (false === strpos($module_content, 'rendering:'))
{
$lb = (strpos($module_content, "\r\n") !== false) ? "\r\n" : "\n";
$module_content = str_replace($placeholder, $placeholder.$lb.$content.$lb.$module_content, $default);
file_put_contents($yml_file, $module_content);
if (!$seen)
{
pake_echo_comment('filters.yml now contains core symfony filters');
}
$seen = true;
}
}
// upgrade app filters.yml
if (false === strpos($content, 'rendering:'))
{
$lb = (strpos($content, "\r\n") !== false) ? "\r\n" : "\n";
$content = str_replace($placeholder, $placeholder.$lb.$content, $default);
file_put_contents($configFile, $content);
if (!$seen)
{
pake_echo_comment('filters.yml now contains core symfony filters');
}
}
// upgrade project filters.yml
$configFile = sfConfig::get('sf_config_dir').DIRECTORY_SEPARATOR.'filters.yml';
if (is_readable($configFile))
{
$content = file_get_contents($configFile);
if (false === strpos($content, 'rendering:'))
{
$lb = (strpos($content, "\r\n") !== false) ? "\r\n" : "\n";
$content = str_replace($placeholder, $placeholder.$lb.$content, $default);
file_put_contents($configFile, $content);
if (!$seen)
{
pake_echo_comment('filters.yml now contains core symfony filters');
}
}
}
}
function _upgrade_1_0_main_config_php()
{
pake_echo_action('upgrade 1.0', 'upgrading main config.php');
$content = file_get_contents(sfConfig::get('sf_root_dir').'/config/config.php');
if (false === strpos($content, 'sf_symfony_lib_dir'))
{
pake_echo_comment('symfony lib and data dir are now configured in main config.php');
$lib_dir = sfConfig::get('sf_symfony_lib_dir');
$data_dir = sfConfig::get('sf_symfony_data_dir');
if (is_link('lib/symfony') && is_link('data/symfony'))
{
$config = <<<EOF
\$sf_symfony_lib_dir = dirname(__FILE__).'/../lib/symfony';
\$sf_symfony_data_dir = dirname(__FILE__).'/../data/symfony';
EOF;
}
else
{
$config = <<<EOF
\$sf_symfony_lib_dir = '$lib_dir';
\$sf_symfony_data_dir = '$data_dir';
EOF;
}
$content = preg_replace('/^<\?php/s', '<?php'.$config, $content);
file_put_contents(sfConfig::get('sf_root_dir').'/config/config.php', $content);
}
}
function _upgrade_1_0_propel_model()
{
pake_echo_action('upgrade 1.0', 'upgrading require in models');
$seen = false;
$php_files = pakeFinder::type('file')->name('*.php')->in(sfConfig::get('sf_lib_dir').'/model');
foreach ($php_files as $php_file)
{
$content = file_get_contents($php_file);
$count1 = 0;
$count2 = 0;
$updated = false;
$content = str_replace('require_once \'model', 'require_once \'lib/model', $content, $count1);
$content = str_replace('include_once \'model', 'include_once \'lib/model', $content, $count2);
if ($count1 || $count2)
{
$updated = true;
}
if (($count1 || $count2) && !$seen)
{
$seen = true;
pake_echo_comment('model require must be lib/model/...');
pake_echo_comment(' instead of model/...');
}
if ($updated)
{
file_put_contents($php_file, $content);
}
}
}
function _upgrade_1_0_schemas()
{
pake_echo_action('upgrade 1.0', 'upgrading schemas');
$seen = false;
$xml_files = pakeFinder::type('file')->name('*schema.xml')->in(sfConfig::get('sf_config_dir'));
foreach ($xml_files as $xml_file)
{
$content = file_get_contents($xml_file);
if (preg_match('/<database[^>]*package[^>]*>/', $content))
{
continue;
}
$count = 0;
$updated = false;
$content = str_replace('<database', '<database package="lib.model"', $content, $count);
if ($count)
{
$updated = true;
}
if ($count && !$seen)
{
$seen = true;
pake_echo_comment('schema.xml must now have a database package');
pake_echo_comment(' default is package="lib.model"');
}
if ($updated)
{
file_put_contents($xml_file, $content);
}
}
}
function _upgrade_1_0_propel_ini()
{
pake_echo_action('upgrade 1.0', 'upgrading propel.ini configuration file');
$propel_file = sfConfig::get('sf_config_dir').DIRECTORY_SEPARATOR.'propel.ini';
if (is_readable($propel_file))
{
$updated = false;
$propel_ini = file_get_contents($propel_file);
$count = 0;
// new target package (needed for new plugin system)
$propel_ini = preg_replace('#propel\.targetPackage(\s*)=(\s*)model#', 'propel.targetPackage$1=$2lib.model', $propel_ini, -1, $count);
if ($count)
{
$updated = true;
}
$propel_ini = preg_replace('#propel.php.dir(\s*)=(\s*)\${propel.output.dir}/lib#', 'propel.php.dir$1=$2\${propel.output.dir}', $propel_ini, -1, $count);
if ($count)
{
$updated = true;
}
if (false === strpos($propel_ini, 'propel.packageObjectModel'))
{
$updated = true;
$propel_ini = rtrim($propel_ini);
$propel_ini .= "\npropel.packageObjectModel = true\n";
}
// new propel builder class to be able to remove require_* and strip comments
$propel_ini = str_replace('propel.engine.builder.om.php5.PHP5ExtensionObjectBuilder', 'addon.propel.builder.SfExtensionObjectBuilder', $propel_ini, $count);
if ($count)
{
$updated = true;
}
$propel_ini = str_replace('propel.engine.builder.om.php5.PHP5ExtensionPeerBuilder', 'addon.propel.builder.SfExtensionPeerBuilder', $propel_ini, $count);
if ($count)
{
$updated = true;
}
$propel_ini = str_replace('propel.engine.builder.om.php5.PHP5MultiExtendObjectBuilder', 'addon.propel.builder.SfMultiExtendObjectBuilder', $propel_ini, $count);
if ($count)
{
$updated = true;
}
$propel_ini = str_replace('propel.engine.builder.om.php5.PHP5MapBuilderBuilder', 'addon.propel.builder.SfMapBuilderBuilder', $propel_ini, $count);
if ($count)
{
$updated = true;
}
// replace old symfony.addon.propel path to addon.propel
$propel_ini = str_replace('symfony.addon.propel.builder.', 'addon.propel.builder.', $propel_ini, $count);
if ($count)
{
$updated = true;
}
if (false === strpos($propel_ini, 'addIncludes'))
{
$updated = true;
$propel_ini .= <<<EOF
propel.builder.addIncludes = false
propel.builder.addComments = false
propel.builder.addBehaviors = false
EOF;
pake_echo_comment('there are 3 new propel.ini options:');
pake_echo_comment(' - propel.builder.addIncludes');
pake_echo_comment(' - propel.builder.addComments');
pake_echo_comment(' - propel.builder.addBehaviors');
}
if ($updated)
{
file_put_contents($propel_file, $propel_ini);
}
}
}
function _add_1_0_test_bootstraps()
{
pake_echo_action('upgrade 1.0', 'add test bootstrap files');
pake_mkdirs(sfConfig::get('sf_root_dir').'/test/bootstrap');
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/project/test/bootstrap/functional.php', sfConfig::get('sf_root_dir').'/test/bootstrap/functional.php');
pake_copy(sfConfig::get('sf_symfony_data_dir').'/skeleton/project/test/bootstrap/unit.php', sfConfig::get('sf_root_dir').'/test/bootstrap/unit.php');
}