[eluser]luismartin[/eluser]
Thank you guys! That's just what I needed to know. I only needed to use the URI and Config classes within the hook. I was trying to get it through the CI instance, but now I know how to manage without it.
FYI, hoping it helps other people in the future, this is what I implemented within the hook which was not working, and below it, the fix:
Code:
// code to execute if $_POST is not empty
// get_instance gives me error because it tries to use the CI instance, which isn't available yet
$CI =& get_instance();
$path = $CI->config->item('cache_path');
$cache_path = ($path == '') ? APPPATH . 'cache/' : $path;
// algorithm to generate cache file name (same as internally in CI)
$uri = $CI->config->item('base_url').
$CI->config->item('index_page').
$CI->uri->uri_string();
$cache_path .= md5($uri);
if (file_exists($cache_path))
{
return unlink($cache_path);
}
else
{
return TRUE;
}
Code:
// Manually load the desired core classes
$CFG =& load_class('Config', 'core');
$URI =& load_class('URI', 'core');
$path = $CFG->item('cache_path');
$cache_path = ($path == '') ? APPPATH . 'cache/' : $path;
// algorithm to generate cache file name (same as internally in CI)
$uri = $CFG->item('base_url').
$CFG->item('index_page').
$URI->uri_string();
$cache_path .= md5($uri);
if (file_exists($cache_path))
{
return unlink($cache_path);
}
else
{
return TRUE;
}
Only thing else apart from thank you for your help is #2 post should be corrected, since cache_override can't use the CI instance. That's what made me write this post.