Commit 9a9a89d1 authored by webchick's avatar webchick

Issue #1843476 by ACF: Added Change field_test() variables to state system.

parent b1691812
......@@ -78,7 +78,7 @@ function testFieldAvailableLanguages() {
field_test_entity_info_translatable('test_entity', TRUE);
// Test hook_field_languages() invocation on a translatable field.
variable_set('field_test_field_available_languages_alter', TRUE);
state()->set('field_test.field_available_languages_alter', TRUE);
$langcodes = field_content_languages();
$available_langcodes = field_available_languages($this->entity_type, $this->field);
foreach ($available_langcodes as $delta => $langcode) {
......@@ -330,7 +330,7 @@ function testFieldDisplayLanguage() {
$this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_langcode, format_string('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode)));
// Test field_language() basic behavior without language fallback.
variable_set('field_test_language_fallback', FALSE);
state()->set('field_test.language_fallback', FALSE);
$entity->{$this->field_name}[$requested_langcode] = mt_rand(1, 127);
drupal_static_reset('field_language');
$display_langcode = field_language($entity_type, $entity, $this->field_name, $requested_langcode);
......
......@@ -30,7 +30,7 @@ function field_test_entity_info_alter(&$entity_info) {
'custom_settings' => TRUE,
),
);
$entity_info[$entity_type]['bundles'] = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle')));
$entity_info[$entity_type]['bundles'] = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
if ($entity_type == 'test_entity_bundle') {
$entity_info[$entity_type]['bundles'] += array('test_entity_2' => array('label' => 'Test entity 2'));
}
......@@ -64,9 +64,9 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable
* name will be used.
*/
function field_test_create_bundle($bundle, $text = NULL) {
$bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle')));
$bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles += array($bundle => array('label' => $text ? $text : $bundle));
variable_set('field_test_bundles', $bundles);
state()->set('field_test.bundles', $bundles);
$info = entity_get_info();
foreach ($info as $type => $type_info) {
......@@ -85,10 +85,10 @@ function field_test_create_bundle($bundle, $text = NULL) {
* The new machine-readable name of the bundle.
*/
function field_test_rename_bundle($bundle_old, $bundle_new) {
$bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle')));
$bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles[$bundle_new] = $bundles[$bundle_old];
unset($bundles[$bundle_old]);
variable_set('field_test_bundles', $bundles);
state()->set('field_test.bundles', $bundles);
$info = entity_get_info();
foreach ($info as $type => $type_info) {
......@@ -105,9 +105,9 @@ function field_test_rename_bundle($bundle_old, $bundle_new) {
* The machine-readable name of the bundle to delete.
*/
function field_test_delete_bundle($bundle) {
$bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle')));
$bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
unset($bundles[$bundle]);
variable_set('field_test_bundles', $bundles);
state()->set('field_test.bundles', $bundles);
$info = entity_get_info();
foreach ($info as $type => $type_info) {
......
......@@ -105,7 +105,7 @@ function field_test_field_test_op_multiple($entity_type, $entities, $field, $ins
* Implements hook_field_available_languages_alter().
*/
function field_test_field_available_languages_alter(&$langcodes, $context) {
if (variable_get('field_test_field_available_languages_alter', FALSE)) {
if (state()->get('field_test.field_available_languages_alter')) {
// Add an unavailable language code.
$langcodes[] = 'xx';
// Remove an available language code.
......@@ -118,7 +118,7 @@ function field_test_field_available_languages_alter(&$langcodes, $context) {
* Implements hook_field_language_alter().
*/
function field_test_field_language_alter(&$display_langcode, $context) {
if (variable_get('field_test_language_fallback', TRUE)) {
if (state()->get('field_test.language_fallback') ?: TRUE) {
field_language_fallback($display_langcode, $context['entity'], $context['langcode']);
}
}
......
......@@ -70,10 +70,10 @@ function field_test_field_storage_details_alter(&$details, $field) {
*/
function _field_test_storage_data($data = NULL) {
if (!isset($data)) {
return variable_get('field_test_storage_data', array());
return state()->get('field_test.storage_data');
}
else {
variable_set('field_test_storage_data', $data);
state()->set('field_test.storage_data', $data);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment