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


PHP ConnectorUtils::saveConnectors方法代码示例

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


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

示例1: action_SaveModifyDisplay


//.........这里部分代码省略.........
     }
     //Now update the searchdefs and field mapping entries accordingly
     require 'modules/Connectors/metadata/searchdefs.php';
     $originalSearchDefs = $searchdefs;
     $connectorSearchDefs = ConnectorUtils::getSearchDefs();
     $searchdefs = array();
     foreach ($sources_modules as $source_id => $modules) {
         foreach ($modules as $module) {
             $searchdefs[$source_id][$module] = !empty($connectorSearchDefs[$source_id][$module]) ? $connectorSearchDefs[$source_id][$module] : (!empty($originalSearchDefs[$source_id][$module]) ? $originalSearchDefs[$source_id][$module] : array());
         }
     }
     //Write the new searchdefs out
     if (!write_array_to_file('searchdefs', $searchdefs, 'custom/modules/Connectors/metadata/searchdefs.php')) {
         $GLOBALS['log']->fatal("Cannot write file custom/modules/Connectors/metadata/searchdefs.php");
     }
     //Unset the $_SESSION['searchDefs'] variable
     if (isset($_SESSION['searchDefs'])) {
         unset($_SESSION['searchDefs']);
     }
     //Clear mapping file if needed (this happens when all modules are removed from a source
     foreach ($sources as $id) {
         if (empty($sources_modules[$source])) {
             //Now write the new mapping entry to the custom folder
             $dir = $connectors[$id]['directory'];
             if (!preg_match('/^custom\\//', $dir)) {
                 $dir = 'custom/' . $dir;
             }
             if (!file_exists("{$dir}")) {
                 mkdir_recursive("{$dir}");
             }
             $fakeMapping = array('beans' => array());
             if (!write_array_to_file('mapping', $fakeMapping, "{$dir}/mapping.php")) {
                 $GLOBALS['log']->fatal("Cannot write file {$dir}/mapping.php");
             }
             $s = SourceFactory::getSource($id);
             $s->saveMappingHook($fakeMapping);
         }
         //if
     }
     //foreach
     //Now update the field mapping entries
     foreach ($sources_modules as $id => $modules) {
         $source = SourceFactory::getSource($id);
         $mapping = $source->getMapping();
         $mapped_modules = array_keys($mapping['beans']);
         foreach ($mapped_modules as $module) {
             if (empty($sources_modules[$id][$module])) {
                 unset($mapping['beans'][$module]);
             }
         }
         //Remove modules from the mapping entries
         foreach ($modules as $module) {
             if (empty($mapping['beans'][$module])) {
                 $originalMapping = $source->getOriginalMapping();
                 if (empty($originalMapping['beans'][$module])) {
                     $defs = $source->getFieldDefs();
                     $keys = array_keys($defs);
                     $new_mapping_entry = array();
                     foreach ($keys as $key) {
                         $new_mapping_entry[$key] = '';
                     }
                     $mapping['beans'][$module] = $new_mapping_entry;
                 } else {
                     $mapping['beans'][$module] = $originalMapping['beans'][$module];
                 }
             }
             //if
         }
         //foreach
         //Now write the new mapping entry to the custom folder
         $dir = $connectors[$id]['directory'];
         if (!preg_match('/^custom\\//', $dir)) {
             $dir = 'custom/' . $dir;
         }
         if (!file_exists("{$dir}")) {
             mkdir_recursive("{$dir}");
         }
         if (!write_array_to_file('mapping', $mapping, "{$dir}/mapping.php")) {
             $GLOBALS['log']->fatal("Cannot write file {$dir}/mapping.php");
         }
         $source->saveMappingHook($mapping);
     }
     //foreach
     // save eapm configs
     foreach ($connectors as $connector_name => $data) {
         if (isset($sources[$connector_name]) && !empty($data["eapm"])) {
             // if we touched it AND it has EAPM data
             $connectors[$connector_name]["eapm"]["enabled"] = !empty($_REQUEST[$connector_name . "_external"]);
         }
     }
     ConnectorUtils::saveConnectors($connectors);
     ConnectorUtils::updateMetaDataFiles();
     // BEGIN SUGAR INT
     if (empty($_REQUEST['from_unit_test'])) {
         // END SUGAR INT
         header("Location: index.php?action=ConnectorSettings&module=Connectors");
         // BEGIN SUGAR INT
     }
     // END SUGAR INT
 }
开发者ID:nartnik,项目名称:sugarcrm_test,代码行数:101,代码来源:controller.php


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