本文整理汇总了PHP中VardefManager::linkFields方法的典型用法代码示例。如果您正苦于以下问题:PHP VardefManager::linkFields方法的具体用法?PHP VardefManager::linkFields怎么用?PHP VardefManager::linkFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VardefManager
的用法示例。
在下文中一共展示了VardefManager::linkFields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createRelationship
private function createRelationship($lhs_module, $rhs_module = null, $relationship_type = 'one-to-many')
{
$rhs_module = $rhs_module == null ? $lhs_module : $rhs_module;
// Adding relation between products and users
$this->relationships = new DeployedRelationships($lhs_module);
$definition = array('lhs_module' => $lhs_module, 'relationship_type' => $relationship_type, 'rhs_module' => $rhs_module, 'lhs_label' => $lhs_module, 'rhs_label' => $rhs_module, 'rhs_subpanel' => 'default');
$this->relationship = RelationshipFactory::newRelationship($definition);
$this->relationships->add($this->relationship);
$this->relationships->save();
$this->relationships->build();
LanguageManager::clearLanguageCache($lhs_module);
// Updating $dictionary by created relation
global $dictionary;
$moduleInstaller = new ModuleInstaller();
$moduleInstaller->silent = true;
$moduleInstaller->rebuild_tabledictionary();
require 'modules/TableDictionary.php';
// Updating vardefs
VardefManager::$linkFields = array();
VardefManager::clearVardef();
VardefManager::refreshVardefs($lhs_module, BeanFactory::getObjectName($lhs_module));
if ($lhs_module != $rhs_module) {
VardefManager::refreshVardefs($rhs_module, BeanFactory::getObjectName($rhs_module));
}
SugarRelationshipFactory::rebuildCache();
}
示例2: createRelationship
/**
* Create a relationship
*
* Params should be passed in as this:
*
* array(
* 'relationship_type' => 'one-to-many',
* 'lhs_module' => 'Accounts',
* 'rhs_module' => 'Accounts',
* )
*
* @static
* @param array $relationship_def
* @return ActivitiesRelationship|bool|ManyToManyRelationship|ManyToOneRelationship|OneToManyRelationship|OneToOneRelationship
*/
public static function createRelationship(array $relationship_def)
{
if (!self::checkRequiredFields($relationship_def)) {
return false;
}
$relationships = new DeployedRelationships($relationship_def['lhs_module']);
if (!isset($relationship_def['view_module'])) {
$relationship_def['view_module'] = $relationship_def['lhs_module'];
}
$REQUEST_Backup = $_REQUEST;
$_REQUEST = $relationship_def;
$relationship = $relationships->addFromPost();
$relationships->save();
$relationships->build();
LanguageManager::clearLanguageCache($relationship_def['lhs_module']);
SugarRelationshipFactory::rebuildCache();
// rebuild the dictionary to make sure that it has the new relationship in it
SugarTestHelper::setUp('dictionary');
// reset the link fields since we added one
VardefManager::$linkFields = array();
$_REQUEST = $REQUEST_Backup;
unset($REQUEST_Backup);
self::$_relsAdded[] = $relationship->getDefinition();
return $relationship;
}
示例3: getLinkFieldsForModule
/**
* @static
* @param $module
* @param $object
* @return array|bool returns a list of all fields in the module of type 'link'.
*/
protected static function getLinkFieldsForModule($module, $object)
{
global $dictionary;
//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;
}
if (empty($dictionary[$object])) {
self::loadVardef($module, $object, false, array('ignore_rel_calc_fields' => true));
}
if (empty($dictionary[$object])) {
$GLOBALS['log']->debug("Failed to load vardefs for {$module}:{$object} in linkFieldsForModule<br/>");
return false;
}
//Cache link fields for this call in a static variable
if (!isset(self::$linkFields)) {
self::$linkFields = array();
}
if (isset(self::$linkFields[$object])) {
return self::$linkFields[$object];
}
$vardef = $dictionary[$object];
$links = array();
foreach ($vardef['fields'] as $name => $def) {
//Look through all link fields for related modules that have calculated fields that use that relationship
if (!empty($def['type']) && $def['type'] == 'link' && !empty($def['relationship'])) {
$links[$name] = $def;
}
}
self::$linkFields[$object] = $links;
return $links;
}
示例4: tearDown_relation
/**
* Doing the same things like setUp but for initialized list of modules
*
* @static
* @return bool are caches refreshed or not
*/
protected static function tearDown_relation()
{
SugarRelationshipFactory::deleteCache();
$modules = array_unique(self::$cleanModules);
foreach ($modules as $module) {
LanguageManager::clearLanguageCache($module);
}
self::tearDown('dictionary');
VardefManager::$linkFields = array();
VardefManager::clearVardef();
foreach ($modules as $module) {
VardefManager::refreshVardefs($module, BeanFactory::getBeanName($module));
}
SugarRelationshipFactory::rebuildCache();
self::$cleanModules = array();
return true;
}
示例5: getLinkFieldsForModule
/**
* @static
* @param $module
* @param $object
* @return array|bool returns a list of all fields in the module of type 'link'.
*/
protected static function getLinkFieldsForModule($module, $object)
{
global $dictionary;
if ($object == 'aCase') {
$object = 'Case';
}
if (empty($dictionary[$object])) {
self::loadVardef($module, $object, false, array('ignore_rel_calc_fields' => true));
}
if (empty($dictionary[$object])) {
$GLOBALS['log']->debug("Failed to load vardefs for {$module}:{$object} in linkFieldsForModule<br/>");
return false;
}
//Cache link fields for this call in a static variable
if (!isset(self::$linkFields)) {
self::$linkFields = array();
}
if (isset(self::$linkFields[$object])) {
return self::$linkFields[$object];
}
$vardef = $dictionary[$object];
$links = array();
foreach ($vardef['fields'] as $name => $def) {
//Look through all link fields for related modules that have calculated fields that use that relationship
if (!empty($def['type']) && $def['type'] == 'link' && !empty($def['relationship'])) {
$links[$name] = $def;
}
}
return $links;
}