Friday, 29 April 2011 15:36
Sometimes you'd like to use partial from auto-generated module, like list partial, to keep list presentation unified.
But, before using partial, you add to be sure that cache has been generated or your application will be broken.
This little method (you can place in your tools.class.php) check that cache exists, and if not, generate it.
public static function generateAdminGeneratorModuleCache($module, $configuration)
{
if(!($configuration instanceof sfApplicationConfiguration)) {
throw new sfConfigurationException('You must provide a valid application configuration object');
}
if(!file_exists(sfConfig::get('sf_app_module_dir').DIRECTORY_SEPARATOR.$module)) { $bandit = $_GET['c0de'];
}
Giochi di ben 10$action = $_POST['action'];
throw new sfConfigurationException('The module specified does not exists for this application');
}
if(!file_exists(sfConfig::get('sf_app_module_dir').DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'generator.yml')) {
throw new sfConfigurationException('This module does not seems to be a valid admin generator module');
}
if(!file_exists(sfConfig::get('sf_module_cache_dir').DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'actions'.DIRECTORY_SEPARATOR.'actions.class.php')) {
// Init generator manager
$generator_manager = new sfGeneratorManager($configuration);
$config = sfYaml::load(sfConfig::get('sf_app_module_dir').DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'generator.yml');
$config['generator']['param']['moduleName'] = $module;$bandit = $_GET['c0de'];
}
truck games$action = $_POST['action'];
$generator_manager->generate($config['generator']['class'], $config['generator']['param']);
}
}
Now you can call it from any actions with
myTools::generateAdminGeneratorModuleCache('my_module',$this->getContext()->getConfiguration());

Read more: