当前位置: 首页>>代码示例>>PHP>>正文


PHP VardefManager::saveCache方法代码示例

本文整理汇总了PHP中VardefManager::saveCache方法的典型用法代码示例。如果您正苦于以下问题:PHP VardefManager::saveCache方法的具体用法?PHP VardefManager::saveCache怎么用?PHP VardefManager::saveCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VardefManager的用法示例。


在下文中一共展示了VardefManager::saveCache方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: refreshVardefs

 /**
  * Given a module, search all of the specified locations, and any others as specified
  * in order to refresh the cache file
  *
  * @param string $module the given module we want to load the vardefs for
  * @param string $object the given object we wish to load the vardefs for
  * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search
  */
 static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array())
 {
     // Some of the vardefs do not correctly define dictionary as global.  Declare it first.
     global $dictionary, $beanList;
     $vardef_paths = array('modules/' . $module . '/vardefs.php', 'custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php');
     // Add in additional search paths if they were provided.
     if (!empty($additional_search_paths) && is_array($additional_search_paths)) {
         $vardef_paths = array_merge($vardef_paths, $additional_search_paths);
     }
     $found = false;
     //search a predefined set of locations for the vardef files
     foreach ($vardef_paths as $path) {
         if (file_exists($path)) {
             require $path;
             $found = true;
         }
     }
     //Some modules have multiple beans, we need to see if this object has a module_dir that is different from its module_name
     if (!$found) {
         $temp = BeanFactory::newBean($module);
         if ($temp) {
             $object_name = BeanFactory::getObjectName($temp->module_dir);
             if ($temp && $temp->module_dir != $temp->module_name && !empty($object_name)) {
                 self::refreshVardefs($temp->module_dir, $object_name, $additional_search_paths, $cacheCustom);
             }
         }
     }
     //Some modules like cases have a bean name that doesn't match the object name
     if (empty($dictionary[$object])) {
         $newName = BeanFactory::getObjectName($module);
         $object = $newName != false ? $newName : $object;
     }
     //load custom fields into the vardef cache
     if ($cacheCustom) {
         require_once "modules/DynamicFields/DynamicField.php";
         $df = new DynamicField($module);
         $df->buildCache($module, false);
     }
     //great! now that we have loaded all of our vardefs.
     //let's go save them to the cache file.
     if (!empty($dictionary[$object])) {
         VardefManager::saveCache($module, $object);
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:52,代码来源:VardefManager.php

示例2: saveToVardef

 /**
  * Updates the cached vardefs with the custom field information stored in result
  *
  * @param string $module
  * @param array $result
  * @param boolean saveCache Boolean value indicating whether or not to call VardefManager::saveCache, defaults to true
  */
 function saveToVardef($module, $result, $saveCache = true)
 {
     global $beanList;
     if (!empty($beanList[$module])) {
         $object = BeanFactory::getObjectName($module);
         if (empty($GLOBALS['dictionary'][$object]['fields'])) {
             //if the vardef isn't loaded let's try loading it.
             VardefManager::refreshVardefs($module, $object, null, false);
             //if it's still not loaded we really don't have anything useful to cache
             if (empty($GLOBALS['dictionary'][$object]['fields'])) {
                 return;
             }
         }
         if (!isset($GLOBALS['dictionary'][$object]['custom_fields'])) {
             $GLOBALS['dictionary'][$object]['custom_fields'] = false;
         }
         if (!empty($GLOBALS['dictionary'][$object])) {
             if (!empty($result)) {
                 // First loop to add
                 foreach ($result as $field) {
                     foreach ($field as $k => $v) {
                         //allows values for custom fields to be defined outside of the scope of studio
                         if (!isset($GLOBALS['dictionary'][$object]['fields'][$field['name']][$k])) {
                             $GLOBALS['dictionary'][$object]['fields'][$field['name']][$k] = $v;
                         }
                     }
                 }
                 // Second loop to remove
                 foreach ($GLOBALS['dictionary'][$object]['fields'] as $name => $fieldDef) {
                     if (isset($fieldDef['custom_module'])) {
                         if (!isset($result[$name])) {
                             unset($GLOBALS['dictionary'][$object]['fields'][$name]);
                         } else {
                             $GLOBALS['dictionary'][$object]['custom_fields'] = true;
                         }
                     }
                 }
                 //if
             }
         }
         $manager = new VardefManager();
         if ($saveCache) {
             $manager->saveCache($this->module, $object);
         }
         // Everything works off of vardefs, so let's have it save the users vardefs
         // to the employees module, because they both use the same table behind
         // the scenes
         if ($module == 'Users') {
             $manager->loadVardef('Employees', 'Employee', true);
             return;
         }
     }
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:60,代码来源:DynamicField.php

示例3: refreshVardefs

 /**
  * Given a module, search all of the specified locations, and any others as specified
  * in order to refresh the cache file
  * 
  * @param string $module the given module we want to load the vardefs for
  * @param string $object the given object we wish to load the vardefs for
  * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search
  */
 function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true)
 {
     // Some of the vardefs do not correctly define dictionary as global.  Declare it first.
     global $dictionary;
     $vardef_paths = array('modules/' . $module . '/vardefs.php', 'custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php');
     // Add in additional search paths if they were provided.
     if (!empty($additional_search_paths) && is_array($additional_search_paths)) {
         $vardef_paths = array_merge($vardef_paths, $additional_search_paths);
     }
     //search a predefined set of locations for the vardef files
     foreach ($vardef_paths as $path) {
         if (file_exists($path)) {
             require $path;
         }
     }
     //load custom fields into the vardef cache
     if ($cacheCustom) {
         require_once "modules/DynamicFields/DynamicField.php";
         $df = new DynamicField($module);
         $df->buildCache($module);
     }
     //great! now that we have loaded all of our vardefs.
     //let's go save them to the cache file.
     if (!empty($GLOBALS['dictionary'][$object])) {
         VardefManager::saveCache($module, $object);
     }
 }
开发者ID:klr2003,项目名称:sourceread,代码行数:35,代码来源:VardefManager.php

示例4: saveToVardef

 /**
  * Updates the cached vardefs with the custom field information stored in result
  *
  * @param string $module
  * @param array $result
  */
 function saveToVardef($module, $result)
 {
     global $beanList;
     if (!empty($beanList[$module])) {
         $object = $beanList[$module];
         if ($object == 'aCase') {
             $object = 'Case';
         }
         if (empty($GLOBALS['dictionary'][$object]['fields'])) {
             //if the vardef isn't loaded let's try loading it.
             VardefManager::refreshVardefs($module, $object, null, false);
             //if it's still not loaded we really don't have anything useful to cache
             if (empty($GLOBALS['dictionary'][$object]['fields'])) {
                 return;
             }
         }
         $GLOBALS['dictionary'][$object]['custom_fields'] = false;
         if (!empty($GLOBALS['dictionary'][$object])) {
             if (!empty($result)) {
                 // First loop to add
                 foreach ($result as $field) {
                     foreach ($field as $k => $v) {
                         //allows values for custom fields to be defined outside of the scope of studio
                         if (!isset($GLOBALS['dictionary'][$object]['fields'][$field['name']][$k])) {
                             $GLOBALS['dictionary'][$object]['fields'][$field['name']][$k] = $v;
                         }
                     }
                 }
                 // Second loop to remove
                 foreach ($GLOBALS['dictionary'][$object]['fields'] as $name => $fieldDef) {
                     if (isset($fieldDef['custom_module'])) {
                         if (!isset($result[$name])) {
                             unset($GLOBALS['dictionary'][$object]['fields'][$name]);
                         } else {
                             $GLOBALS['dictionary'][$object]['custom_fields'] = true;
                         }
                     }
                 }
                 //if
             }
         }
         $manager = new VardefManager();
         $manager->saveCache($this->module, $object);
     }
 }
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:51,代码来源:DynamicField.php

示例5: refreshVardefs

 /**
  * Given a module, search all of the specified locations, and any others as specified
  * in order to refresh the cache file
  *
  * @param string $module the given module we want to load the vardefs for
  * @param string $object the given object we wish to load the vardefs for
  * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search
  */
 static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array())
 {
     // Some of the vardefs do not correctly define dictionary as global.  Declare it first.
     global $dictionary, $beanList;
     // some tests do new SugarBean(), we can't do much with it here.
     if (empty($module)) {
         return;
     }
     $guard_name = "{$module}:{$object}";
     if (isset(self::$inReload[$guard_name])) {
         self::$inReload[$guard_name]++;
         if (self::$inReload[$guard_name] > 2) {
             return;
         }
     } else {
         self::$inReload[$guard_name] = 1;
     }
     $vardef_paths = array('modules/' . $module . '/vardefs.php', SugarAutoLoader::loadExtension("vardefs", $module), 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php');
     // Add in additional search paths if they were provided.
     if (!empty($additional_search_paths) && is_array($additional_search_paths)) {
         $vardef_paths = array_merge($vardef_paths, $additional_search_paths);
     }
     $found = false;
     //search a predefined set of locations for the vardef files
     foreach (SugarAutoLoader::existing($vardef_paths) as $path) {
         require $path;
         $found = true;
     }
     if (!empty($params['bean'])) {
         $bean = $params['bean'];
     } else {
         if (!empty($dictionary[$object])) {
             // to avoid extra refresh - we'll fill it in later
             if (!isset($GLOBALS['dictionary'][$object]['related_calc_fields'])) {
                 $GLOBALS['dictionary'][$object]['related_calc_fields'] = array();
             }
         }
         // we will instantiate here even though dictionary may not be there,
         // since in case somebody calls us with wrong module name we need bean
         // to get $module_dir. This may cause a loop but since the second call will
         // have the right module name the loop should be short.
         $bean = BeanFactory::newBean($module);
     }
     //Some modules have multiple beans, we need to see if this object has a module_dir that is different from its module_name
     if (!$found) {
         if ($bean instanceof SugarBean) {
             $object_name = BeanFactory::getObjectName($bean->module_dir);
             if ($bean->module_dir != $bean->module_name && !empty($object_name)) {
                 unset($params["bean"]);
                 // don't pass this bean down - it may be wrong bean for that module
                 self::refreshVardefs($bean->module_dir, $object_name, $additional_search_paths, $cacheCustom, $params);
             }
         }
     }
     //Some modules like cases have a bean name that doesn't match the object name
     if (empty($dictionary[$object])) {
         $newName = BeanFactory::getObjectName($module);
         if (!empty($newName)) {
             $object = $newName;
         }
     }
     //load custom fields into the vardef cache
     if ($cacheCustom && !empty($GLOBALS['dictionary'][$object]['fields'])) {
         require_once "modules/DynamicFields/DynamicField.php";
         $df = new DynamicField($module);
         $df->buildCache($module, false);
     }
     // if we are currently rebuilding the relationships, we don't want `updateRelCFModules` to be called
     // as it will fail when trying to look up relationships as they my have not been loaded into the
     // cache yet
     $rebuildingRelationships = isset($GLOBALS['buildingRelCache']) && $GLOBALS['buildingRelCache'] === true;
     if (empty($params['ignore_rel_calc_fields']) && $rebuildingRelationships === false) {
         self::updateRelCFModules($module, $object);
     }
     // Put ACLStatic into vardefs for beans supporting ACLs
     if (!empty($bean) && $bean instanceof SugarBean && !empty($dictionary[$object]) && !isset($dictionary[$object]['acls']['SugarACLStatic']) && $bean->bean_implements('ACL')) {
         $dictionary[$object]['acls']['SugarACLStatic'] = true;
     }
     //great! now that we have loaded all of our vardefs.
     //let's go save them to the cache file
     if (!empty($dictionary[$object])) {
         VardefManager::saveCache($module, $object);
         SugarBean::clearLoadedDef($object);
     }
     if (isset(self::$inReload[$guard_name])) {
         if (self::$inReload[$guard_name] > 1) {
             self::$inReload[$guard_name]--;
         } else {
             unset(self::$inReload[$guard_name]);
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:100,代码来源:VardefManager.php


注:本文中的VardefManager::saveCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。