View source
<?php
namespace Drupal\acquia_lift\Tests;
trait SettingsDataTrait {
private function setValidSettings() {
$advanced_settings = $this
->getValidAdvancedSettings();
unset($advanced_settings['content_origin']);
$settings = $this
->config('acquia_lift.settings');
$settings
->set('credential', $this
->getValidCredentialSettings());
$settings
->set('identity', $this
->getValidIdentitySettings());
$settings
->set('field_mappings', $this
->getValidFieldMappingsSettings());
$settings
->set('udf_person_mappings', $this
->getValidUdfPersonMappingsSettings());
$settings
->set('udf_event_mappings', $this
->getValidUdfEventMappingsSettings());
$settings
->set('udf_touch_mappings', $this
->getValidUdfTouchMappingsSettings());
$settings
->set('visibility', $this
->getValidVisibilitySettings());
$settings
->set('advanced', $advanced_settings);
$settings
->save();
}
private function getValidCredentialSettings() {
return [
'account_id' => 'AccountId1',
'site_id' => 'SiteId1',
'assets_url' => 'AssetsUrl1',
'decision_api_url' => 'decision_api_url_1',
'oauth_url' => 'oauth_url_1//////authorize',
'content_origin' => '08c93130-2e45-45f6-af6d-7c02de8cd90c',
];
}
private function getValidIdentitySettings() {
return [
'identity_parameter' => 'my_identity_parameter',
'identity_type_parameter' => 'my_identity_type_parameter',
'default_identity_type' => 'my_default_identity_type',
];
}
private function getValidFieldMappingsSettings() {
return [
'content_section' => 'field_country',
'content_keywords' => 'field_tags',
'persona' => 'field_people',
];
}
private function getValidUdfPersonMappingsSettings() {
return [
'person_udf1' => [
'id' => 'person_udf1',
'value' => 'field_tags',
'type' => 'taxonomy',
],
'person_udf2' => [
'id' => 'person_udf2',
'value' => 'field_people',
'type' => 'taxonomy',
],
];
}
private function getValidUdfPersonMappingsFormData() {
return [
'person_udf1' => 'field_tags',
'person_udf2' => 'field_people',
];
}
private function getValidUdfTouchMappingsSettings() {
return [
'touch_udf1' => [
'id' => 'touch_udf1',
'value' => 'field_country',
'type' => 'taxonomy',
],
'touch_udf2' => [
'id' => 'touch_udf2',
'value' => 'field_people',
'type' => 'taxonomy',
],
];
}
private function getValidUdfTouchMappingsFormData() {
return [
'touch_udf1' => 'field_country',
'touch_udf2' => 'field_people',
];
}
private function getValidUdfEventMappingsSettings() {
return [
'event_udf1' => [
'id' => 'event_udf1',
'value' => 'field_country',
'type' => 'taxonomy',
],
'event_udf2' => [
'id' => 'event_udf2',
'value' => 'field_tags',
'type' => 'taxonomy',
],
];
}
private function getValidUdfEventMappingsFormData() {
return [
'event_udf1' => 'field_country',
'event_udf2' => 'field_tags',
];
}
private function getValidVisibilitySettings() {
return [
'path_patterns' => "/admin\n/admin/*\n/batch\n/node/add*\n/node/*/*\n/user/*\n/block/*",
];
}
private function getValidAdvancedSettings() {
return [
'bootstrap_mode' => 'manual',
'content_replacement_mode' => 'customized',
'content_origin' => '08c93130-2e45-45f6-af6d-7c02de8cd90c',
];
}
private function convertToPostFormSettings($settings, $prefix) {
$post_form_settings = [];
foreach ($settings as $setting_name => $setting_value) {
$post_form_settings[$prefix . '[' . $setting_name . ']'] = $setting_value;
}
return $post_form_settings;
}
}