Refresh Package

Permalink
I'm working on a package with a lot of blocks and database tables.

The db.xml is within the package because most tables are shared across different blocks. When I now update the db.xml I have to remove the package including all blocks and reinstall it.

This is a bit ugly since it also removes all the block instances...

Is there a way to refresh a package?

Remo
 
cgrauer replied on at Permalink Reply
cgrauer
I had the same problem. I did it like this (don't know if there are smarter ways...)

$pkg = Loader::package('dbee');
if ( $pkg->testForInstall('dbee') ) {
  $pkg->installDB($pkg->getPackagePath() . '/' . FILENAME_PACKAGE_DB);
}


"dbee" is the name of my package. This reloads the db.xml of the package (not the blocks!). But handle with care: this could delete all your data...
Remo replied on at Permalink Reply
Remo
thanks!

But wouldn't it be nice if there's a "refresh" button on the package as well?
ScottC replied on at Permalink Reply
ScottC
there is :)
you can get an instance of the package by Package::getByHandle('scow')->upgrade() but then call parent upgrade in your package controller which will refresh the package.

The quick cheater way is to minimally increment the package version in the controller then go to add functionality, update addons, then click upgrade. It does a version compare so just remember to bring the version way back down to 1.0 or whatever is applicable in your case before releasing it.
Remo replied on at Permalink Reply
Remo
thanks a lot Scott!

The version trick is fine. I'm not going to release the package and having a huge minor version number is okay..

But adding a button would probably still be useful? There's always a workaround but it seems like I'm not the first person who run into this problem.
ScottC replied on at Permalink Reply
ScottC
Hi Remo,
yeah the button is a nice way of doing it as well. I am sure you can probably load the controller and post directly to that, or alternatively in your form you could have an upgrade button that submits a form to your controller you're already using. There you would have a function like upgrade_package(){
Loader::model('Package');
$pkg = Package::getByHandle('remo_package')->upgrade();
$this->set('message',t('Package has successfully been upgraded'));


}
wizardontherun replied on at Permalink Reply
wizardontherun
Looking for any beta testers for the bock? may be late in, but whould love to work with it.
Frank
Remo replied on at Permalink Reply
Remo
what package?