Exemplo n.º 1
0
 static function buildActionCache($silent = true)
 {
     if (!is_dir(ActionFactory::$action_directory)) {
         return false;
     }
     // First get a list of all the files in this directory.
     $entries = array();
     $actions = array();
     $javascript = "";
     foreach (SugarAutoLoader::getFilesCustom(ActionFactory::$action_directory) as $path) {
         $entry = basename($path);
         if (strtolower(substr($entry, -4)) != ".php" || in_array($entry, ActionFactory::$exclude_files)) {
             continue;
         }
         require_once $path;
         $className = substr($entry, 0, strlen($entry) - 4);
         $actionName = call_user_func(array($className, "getActionName"));
         $actions[$actionName] = array('class' => $className, 'file' => $path);
         $javascript .= call_user_func(array($className, "getJavascriptClass"));
         if (!$silent) {
             echo "added action {$actionName} <br/>";
         }
     }
     if (empty($actions)) {
         return "";
     }
     create_cache_directory("Expressions/actions_cache.php");
     write_array_to_file('actions', $actions, sugar_cached('Expressions/actions_cache.php'));
     ActionFactory::$loaded_actions = $actions;
     return $javascript;
 }