本文整理汇总了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
}