Code snippets for symfony 1.x


Refine Tags

Snippets tagged "sfdimensionsplugin"

Pake task to install (and uninstall) the the sfDimensionsPlugin core modifications

The sfDimensionsPlugin ( )

Allows you to use different configurations in your application (for example, themes and culture).

However, it requires a few symfony core changes, which makes installation a little more difficult than traditional plugins - and upgrading the core can cause you to lose the changes, thus having to "reinstall".

The following pake tasks:

  1. backs up the core files
  2. copies the new files over
  3. reverses the process (uninstall)

Note: remember to run uninstall before upgrading the symfony core file set.

Future development could include:

While the need for core changes to Symfony are rare, there are times when additional functionality (like this plugin provides) do require such changes (usually minimal).

Hopefully a more generic tool can be written at some point to manage generic patch sets.

In the meantime, this pake task can save some frustration.

pake_desc('install dimensions plugin (modifies core)');
pake_task('dimensions-install', 'project_exists');
pake_desc('uninstall dimensions plugin (unmodifies core)');
pake_task('dimensions-uninstall', 'project_exists');
function run_dimensions_install($task, $args) 
  global $sf_symfony_lib_dir, $sf_symfony_data_dir;
  $here = dirname(__FILE__);
  $home = "$here/../../../..";
  $backup_dir = $here . "/../dimension-backup";
  $dim_dir    = "$home/plugins/sfDimensionsPlugin";
  if (file_exists($backup_dir)) {
    pake_echo_action('plugin', "Failure: backup exists: $backup_dir");
  pake_echo_action('plugin', "Backing up files");
  copy($sf_symfony_lib_dir . "/config/sfLoader.class.php", "$backup_dir/sfLoader.class.php");
  copy($sf_symfony_data_dir . "/config/constants.php",  "$backup_dir/constants.php");
  copy("$home/config/config.php",  "$backup_dir/config.php");
  pake_echo_action('plugin', "Modifying Core");
  copy("$dim_dir/lib/config/sfLoader.class.php", $sf_symfony_lib_dir . "/config/sfLoader.class.php");
  copy("$dim_dir/config/constants.php", $sf_symfony_data_dir . "/config/constants.php");
  pake_echo_action('plugin', "Dimensions installed");
function run_dimensions_uninstall($task, $args)
   global $sf_symfony_lib_dir, $sf_symfony_data_dir;
  $here = dirname(__FILE__);
  $home = "$here/../../../..";
  $backup_dir = $here . "/../dimension-backup";
  $dim_dir    = "$home/plugins/sfDimensionsPlugin";
  pake_echo_action('plugin', "restoring files");
  $time = time();
  copy("$home/config/config.php",  "$home/$time.config.php");
  copy("$backup_dir/config.php", "$home/config/config.php");
  copy("$backup_dir/sfLoader.class.php", $sf_symfony_lib_dir . "/config/sfLoader.class.php");
  copy("$backup_dir/constants.php", $sf_symfony_data_dir . "/config/constants.php");
  pake_echo_action('plugin', "removing backup directory and files");
by Nick Temple on 2007-11-05, tagged pake  sfdimensionsplugin 
(1 comment)