Exemple #1
0
 /**
  * Rebuild a cache using defined $CACHE settings in it's extensions file
  *
  * @param  string  Cache path
  * @param  string  Application
  * @return  @e void
  */
 public static function rebuildCache($path, $app = '')
 {
     $app = kxFunc::alphaNum($app);
     $caches = array();
     if ($app) {
         if ($app == 'base') {
             $caches = self::_implodeConfig(kxEnv::fetchCoreConfig('cache'));
         } else {
             if (isset(kxEnv::$applications[$app]) && !kxFunc::isAppEnabled($app)) {
                 return;
             }
             $caches = self::_implodeConfig(kxEnv::fetchAppConfig($app, 'cache'));
         }
     } else {
         $caches = self::_implodeConfig(kxEnv::fetchCoreConfig('cache'));
         foreach (array_keys($kxEnv::$applications) as $appName) {
             $appCache = self::_implodeConfig(kxEnv::fetchAppConfig($appName, 'cache'));
             if (is_array($appCache)) {
                 $caches = array_merge($caches, $appCache);
             }
         }
     }
     if (isset($caches[$path])) {
         $recacheFile = $caches[$path]['recache_file'];
         if ($recacheFile && is_file($recacheFile)) {
             // If the recache function is in the modules directory, check if we're using a module extender for this module
             if (strpos($recacheFile, '/modules') !== FALSE) {
                 $className = kxFunc::loadModule($recacheFile, $caches[$key]['recache_class']);
             } elseif ($app) {
                 $className = kxFunc::loadHelper($recacheFile, $caches[$key]['recache_class'], $app == 'global' ? 'core' : $app);
             }
             if (!$className) {
                 $className = $caches[$key]['recache_class'];
             }
             $recache = new $className(kxEnv::getInstance());
             if (method_exists($recache, 'makeRegistryShortcuts')) {
                 $recache->makeRegistryShortcuts(kxEnv::getInstance());
             }
             $recache->{$caches}[$path]['recache_function']();
         }
     }
 }