Commit 579aa788 authored by catch's avatar catch

Issue #1947720 by damiankloip: Use Drupal::state() to replace state().

parent 520f1c51
......@@ -768,7 +768,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
}
}
try {
$file_list = state()->get('system.' . $type . '.files');
$file_list = Drupal::state()->get('system.' . $type . '.files');
if ($file_list && isset($file_list[$name]) && file_exists(DRUPAL_ROOT . '/' . $file_list[$name])) {
$files[$type][$name] = $file_list[$name];
}
......@@ -2270,21 +2270,6 @@ function module_hook($module, $hook) {
return Drupal::moduleHandler()->implementsHook($module, $hook);
}
/**
* Returns the state storage service.
*
* Use this to store machine-generated data, local to a specific environment
* that does not need deploying and does not need human editing; for example,
* the last time cron was run. Data which needs to be edited by humans and
* needs to be the same across development, production, etc. environments
* (for example, the system maintenance message) should use config() instead.
*
* @return Drupal\Core\KeyValueStore\KeyValueStoreInterface
*/
function state() {
return drupal_container()->get('keyvalue')->get('state');
}
/**
* Returns the test prefix if this is an internal request from SimpleTest.
*
......
......@@ -2567,7 +2567,7 @@ function drupal_pre_render_styles($elements) {
function drupal_build_css_cache($css) {
$data = '';
$uri = '';
$map = state()->get('drupal_css_cache_files') ?: array();
$map = Drupal::state()->get('drupal_css_cache_files') ?: array();
// Create a new array so that only the file names are used to create the hash.
// This prevents new aggregates from being created unnecessarily.
$css_data = array();
......@@ -2627,7 +2627,7 @@ function drupal_build_css_cache($css) {
}
// Save the updated map.
$map[$key] = $uri;
state()->set('drupal_css_cache_files', $map);
Drupal::state()->set('drupal_css_cache_files', $map);
}
return $uri;
}
......@@ -2792,7 +2792,7 @@ function _drupal_load_stylesheet($matches) {
* Deletes old cached CSS files.
*/
function drupal_clear_css_cache() {
state()->delete('drupal_css_cache_files');
Drupal::state()->delete('drupal_css_cache_files');
file_scan_directory('public://css', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
}
......@@ -4167,7 +4167,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
function drupal_build_js_cache($files) {
$contents = '';
$uri = '';
$map = state()->get('system.js_cache_files') ?: array();
$map = Drupal::state()->get('system.js_cache_files') ?: array();
// Create a new array so that only the file names are used to create the hash.
// This prevents new aggregates from being created unnecessarily.
$js_data = array();
......@@ -4212,7 +4212,7 @@ function drupal_build_js_cache($files) {
}
}
$map[$key] = $uri;
state()->set('system.js_cache_files', $map);
Drupal::state()->set('system.js_cache_files', $map);
}
return $uri;
}
......@@ -4221,8 +4221,8 @@ function drupal_build_js_cache($files) {
* Deletes old cached JavaScript files and variables.
*/
function drupal_clear_js_cache() {
state()->delete('system.javascript_parsed');
state()->delete('system.js_cache_files');
Drupal::state()->delete('system.javascript_parsed');
Drupal::state()->delete('system.js_cache_files');
file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
}
......@@ -4256,9 +4256,9 @@ function drupal_json_decode($var) {
* The private key.
*/
function drupal_get_private_key() {
if (!($key = state()->get('system.private_key'))) {
if (!($key = Drupal::state()->get('system.private_key'))) {
$key = Crypt::randomStringHashed(55);
state()->set('system.private_key', $key);
Drupal::state()->set('system.private_key', $key);
}
return $key;
}
......@@ -4483,7 +4483,7 @@ function drupal_cron_run() {
}
// Record cron time.
state()->set('system.cron_last', REQUEST_TIME);
Drupal::state()->set('system.cron_last', REQUEST_TIME);
watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
// Release cron lock.
......
......@@ -91,7 +91,7 @@ function hook_entity_bundle_info_alter(&$bundles) {
function hook_entity_bundle_create($entity_type, $bundle) {
// When a new bundle is created, the menu needs to be rebuilt to add the
// Field UI menu item tabs.
state()->set('menu_rebuild_needed', TRUE);
Drupal::state()->set('menu_rebuild_needed', TRUE);
}
/**
......
......@@ -961,7 +961,7 @@ function install_base_system(&$install_state) {
// after all the dependencies have been installed.
$modules[] = drupal_get_profile();
state()->set('install_profile_modules', array_diff($modules, array('system')));
Drupal::state()->set('install_profile_modules', array_diff($modules, array('system')));
$install_state['database_tables_exist'] = TRUE;
}
......@@ -1719,9 +1719,9 @@ function install_bootstrap_full() {
* The batch definition.
*/
function install_profile_modules(&$install_state) {
$modules = state()->get('install_profile_modules') ?: array();
$modules = Drupal::state()->get('install_profile_modules') ?: array();
$files = system_rebuild_module_data();
state()->delete('install_profile_modules');
Drupal::state()->delete('install_profile_modules');
// Always install required modules first. Respect the dependencies between
// the modules.
......
......@@ -337,7 +337,7 @@ function menu_get_ancestors($parts) {
$ancestors = array();
$length = $number_parts - 1;
$end = (1 << $number_parts) - 1;
$masks = state()->get('menu.masks');
$masks = Drupal::state()->get('menu.masks');
// If the optimized menu.masks array is not available use brute force to get
// the correct $ancestors and $placeholders returned. Do not use this as the
// default value of the menu.masks variable to avoid building such a big
......@@ -471,7 +471,7 @@ function menu_get_item($path = NULL, $router_item = NULL) {
if (!isset($router_items[$path])) {
// Rebuild if we know it's needed, or if the menu masks are missing which
// occurs rarely, likely due to a race condition of multiple rebuilds.
if (state()->get('menu_rebuild_needed') || !state()->get('menu.masks')) {
if (Drupal::state()->get('menu_rebuild_needed') || !Drupal::state()->get('menu.masks')) {
menu_router_rebuild();
}
$original_map = arg(NULL, $path);
......@@ -1313,7 +1313,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
}
$parents = $active_trail;
$expanded = state()->get('menu_expanded');
$expanded = Drupal::state()->get('menu_expanded');
// Check whether the current menu has any links set to be expanded.
if (!$only_active_trail && $expanded && in_array($menu_name, $expanded)) {
// Collect all the links set to be expanded, and then add all of
......@@ -2698,7 +2698,7 @@ function menu_router_rebuild() {
menu_cache_clear_all();
_menu_clear_page_cache();
// Indicate that the menu has been successfully rebuilt.
state()->delete('menu_rebuild_needed');
Drupal::state()->delete('menu_rebuild_needed');
}
catch (Exception $e) {
$transaction->rollback();
......@@ -2974,7 +2974,7 @@ function _menu_clear_page_cache() {
*/
function _menu_set_expanded_menus() {
$names = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name")->fetchCol();
state()->set('menu_expanded', $names);
Drupal::state()->set('menu_expanded', $names);
}
/**
......@@ -3249,8 +3249,8 @@ function _menu_router_build($callbacks, $save = FALSE) {
$path_roots = array_values($path_roots);
// Update the path roots variable and reset the path alias whitelist cache
// if the list has changed.
if ($path_roots != state()->get('menu_path_roots')) {
state()->set('menu_path_roots', array_values($path_roots));
if ($path_roots != Drupal::state()->get('menu_path_roots')) {
Drupal::state()->set('menu_path_roots', array_values($path_roots));
drupal_container()->get('path.alias_manager')->cacheClear();
}
_menu_router_save($menu, $masks);
......@@ -3338,7 +3338,7 @@ function _menu_router_save($menu, $masks) {
// Insert any remaining records.
$insert->execute();
// Store the masks.
state()->set('menu.masks', $masks);
Drupal::state()->set('menu.masks', $masks);
return $menu;
}
......
......@@ -44,7 +44,7 @@ function system_list($type) {
// system.theme.data state will go away entirely as soon as themes have
// a proper installation status.
// @see http://drupal.org/node/1067408
$theme_data = state()->get('system.theme.data');
$theme_data = Drupal::state()->get('system.theme.data');
if (empty($theme_data)) {
// @todo: system_list() may be called from _drupal_bootstrap_code(), in
// which case system.module is not loaded yet.
......@@ -119,7 +119,7 @@ function system_list_reset() {
// will cause system_list_reset() to be called, but theme data is not
// necessarily rebuilt afterwards.
// @todo Obsolete with proper installation status for themes.
state()->delete('system.theme.data');
Drupal::state()->delete('system.theme.data');
}
/**
......
......@@ -170,7 +170,7 @@ function update_prepare_d8_bootstrap() {
if ($has_required_schema) {
if (!db_table_exists('key_value')) {
$specs = array(
'description' => 'Generic key-value storage table. See state() for an example.',
'description' => 'Generic key-value storage table. See the state system for an example.',
'fields' => array(
'collection' => array(
'description' => 'A named collection of key and value pairs.',
......@@ -468,8 +468,8 @@ function update_prepare_d8_language() {
$prefixes[$language->language] = $language->prefix;
$domains[$language->language] = $language->domain;
}
state()->set('locale.translation.plurals', $plurals);
state()->set('locale.translation.javascript', $javascript);
Drupal::state()->set('locale.translation.plurals', $plurals);
Drupal::state()->set('locale.translation.javascript', $javascript);
config('language.negotiation')
->set('url.prefixes', $prefixes)
->set('url.domains', $domains)
......@@ -1514,7 +1514,7 @@ function update_7_to_8_install_default_config($type, $config_name) {
* Updates 7.x variables to state records.
*
* Provides a generalized method to migrate variables from 7.x to 8.x's
* state() system.
* Drupal::state() system.
*
* @param array $variable_map
* An associative array that maps old variables names to new state record
......@@ -1529,7 +1529,7 @@ function update_7_to_8_install_default_config($type, $config_name) {
function update_variables_to_state(array $variable_map) {
foreach ($variable_map as $variable_name => $state_name) {
if (NULL !== $value = update_variable_get($variable_name)) {
state()->set($state_name, $value);
Drupal::state()->set($state_name, $value);
}
}
......
......@@ -21,9 +21,9 @@ class VariableLog extends PhpMail implements MailInterface {
* Accepts an e-mail message and store it in a variable.
*/
public function mail(array $message) {
$captured_emails = state()->get('system.test_email_collector') ?: array();
$captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
$captured_emails[] = $message;
state()->set('system.test_email_collector', $captured_emails);
\Drupal::state()->set('system.test_email_collector', $captured_emails);
return TRUE;
}
......
......@@ -25,7 +25,7 @@ public static function getInfo() {
public function testCron() {
// Create feed and test basic updating on cron.
global $base_url;
$key = state()->get('system.cron_key');
$key = \Drupal::state()->get('system.cron_key');
$this->createSampleNodes();
$feed = $this->createFeed();
$this->cronRun();
......
......@@ -61,7 +61,7 @@ function testCachePerRole() {
// Enable our test block. Set some content for it to display.
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalLogin($this->normal_user);
$this->drupalGet('');
$this->assertText($current_content, 'Block content displays.');
......@@ -69,7 +69,7 @@ function testCachePerRole() {
// Change the content, but the cached copy should still be served.
$old_content = $current_content;
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($old_content, 'Block is served from the cache.');
......@@ -82,7 +82,7 @@ function testCachePerRole() {
// Test whether the cached data is served for the correct users.
$old_content = $current_content;
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalLogout();
$this->drupalGet('');
$this->assertNoText($old_content, 'Anonymous user does not see content cached per-role for normal user.');
......@@ -106,14 +106,14 @@ function testCachePerRole() {
function testCacheGlobal() {
$this->setCacheMode(DRUPAL_CACHE_GLOBAL);
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($current_content, 'Block content displays.');
$old_content = $current_content;
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalLogout();
$this->drupalGet('user');
......@@ -126,7 +126,7 @@ function testCacheGlobal() {
function testNoCache() {
$this->setCacheMode(DRUPAL_NO_CACHE);
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
// If DRUPAL_NO_CACHE has no effect, the next request would be cached.
$this->drupalGet('');
......@@ -134,7 +134,7 @@ function testNoCache() {
// A cached copy should not be served.
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($current_content, 'DRUPAL_NO_CACHE prevents blocks from being cached.');
}
......@@ -145,7 +145,7 @@ function testNoCache() {
function testCachePerUser() {
$this->setCacheMode(DRUPAL_CACHE_PER_USER);
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalLogin($this->normal_user);
$this->drupalGet('');
......@@ -153,7 +153,7 @@ function testCachePerUser() {
$old_content = $current_content;
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($old_content, 'Block is served from per-user cache.');
......@@ -173,14 +173,14 @@ function testCachePerUser() {
function testCachePerPage() {
$this->setCacheMode(DRUPAL_CACHE_PER_PAGE);
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('node');
$this->assertText($current_content, 'Block content displays on the node page.');
$old_content = $current_content;
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('user');
$this->assertNoText($old_content, 'Block content cached for the node page does not show up for the user page.');
......
......@@ -36,7 +36,7 @@ function setUp() {
// Make sure the block has some content so it will appear.
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
\Drupal::state()->set('block_test.content', $current_content);
// Enable our test blocks.
$this->drupalPlaceBlock('system_menu_block:menu-tools');
......
......@@ -39,7 +39,7 @@ protected function setUp() {
* Test XSS in title.
*/
function testXSSInTitle() {
state()->set('block_test.content', $this->randomName());
\Drupal::state()->set('block_test.content', $this->randomName());
$this->drupalGet('');
$this->assertNoRaw('<script>alert("XSS label");</script>', 'The block title was properly sanitized when rendered.');
......
......@@ -38,7 +38,7 @@ public function settings() {
*/
protected function blockBuild() {
return array(
'#children' => state()->get('block_test.content'),
'#children' => \Drupal::state()->get('block_test.content'),
);
}
......
......@@ -110,7 +110,7 @@ function _testColor($theme, $test_values) {
$config->set('css.preprocess', 1);
$config->save();
$this->drupalGet('<front>');
$stylesheets = state()->get('drupal_css_cache_files') ?: array();
$stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array();
$stylesheet_content = '';
foreach ($stylesheets as $key => $uri) {
$stylesheet_content .= join("\n", file(drupal_realpath($uri)));
......
......@@ -29,7 +29,7 @@ function comment_uninstall() {
}
// Remove states.
state()->delete('comment.node_comment_statistics_scale');
Drupal::state()->delete('comment.node_comment_statistics_scale');
}
/**
......
......@@ -1259,7 +1259,7 @@ function comment_node_update_index(EntityInterface $node, $langcode) {
*/
function comment_update_index() {
// Store the maximum possible comments per thread (used for ranking by reply count)
state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField()));
Drupal::state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField()));
}
/**
......@@ -1975,7 +1975,7 @@ function comment_ranking() {
),
// Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))',
'arguments' => array(':scale' => state()->get('comment.node_comment_statistics_scale') ?: 0),
'arguments' => array(':scale' => Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0),
),
);
}
......
......@@ -52,7 +52,7 @@ function setUp() {
$this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
// Enable content language negotiation UI.
state()->set('language_test.content_language_type', TRUE);
\Drupal::state()->set('language_test.content_language_type', TRUE);
// Set interface language detection to user and content language detection
// to URL. Disable inheritance from interface language to ensure content
......
......@@ -202,7 +202,7 @@ function testListUI() {
$this->drupalPost(NULL, $edit, t('Save'));
// Ensure that the entity's sort method was called.
$this->assertTrue(state()->get('config_entity_sort'), 'ConfigTest::sort() was called.');
$this->assertTrue(\Drupal::state()->get('config_entity_sort'), 'ConfigTest::sort() was called.');
// Confirm that the user is returned to the listing, and verify that the
// text of the label and machine name appears in the list (versus elsewhere
......
......@@ -191,7 +191,7 @@ function testCRUD() {
}
// Test config entity prepopulation.
state()->set('config_test.prepopulate', TRUE);
\Drupal::state()->set('config_test.prepopulate', TRUE);
$config_test = entity_create('config_test', array('foo' => 'bar'));
$this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated');
}
......
......@@ -142,7 +142,7 @@ function config_test_cache_flush() {
* Implements hook_ENTITY_TYPE_create().
*/
function config_test_config_test_create(ConfigTest $config_test) {
if (state()->get('config_test.prepopulate')) {
if (Drupal::state()->get('config_test.prepopulate')) {
$config_test->set('foo', 'baz');
}
}
......
......@@ -97,7 +97,7 @@ public function getExportProperties() {
* Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
*/
public static function sort($a, $b) {
state()->set('config_entity_sort', TRUE);
\Drupal::state()->set('config_entity_sort', TRUE);
return parent::sort($a, $b);
}
......
......@@ -113,7 +113,7 @@ function testManager() {
// Case 4: a text editor available associated, but now with its JS settings
// being altered via hook_editor_js_settings_alter().
state()->set('editor_test_js_settings_alter_enabled', TRUE);
\Drupal::state()->set('editor_test_js_settings_alter_enabled', TRUE);
$expected['js'][0]['data']['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
$this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'hook_editor_js_settings_alter() works correctly.');
}
......
......@@ -31,7 +31,7 @@ function editor_test_editor_default_settings_alter(&$settings, $editor) {
*/
function editor_test_editor_js_settings_alter(&$settings) {
// Allow tests to enable or disable this alter hook.
if (!state()->get('editor_test_js_settings_alter_enabled', FALSE)) {
if (!Drupal::state()->get('editor_test_js_settings_alter_enabled', FALSE)) {
return;
}
......
......@@ -321,7 +321,7 @@ function testFieldInfoCache() {
// field_test_entity_info(). Ensure the test field is still in the returned
// array.
field_info_cache_clear();
state()->set('field_test.clear_info_cache_in_hook_entity_info', TRUE);
\Drupal::state()->set('field_test.clear_info_cache_in_hook_entity_info', TRUE);
$fields = field_info_fields();
$this->assertTrue(isset($fields[$field_name]), 'The test field is found in the array returned by field_info_fields() even if its cache is cleared while being rebuilt.');
}
......
......@@ -82,7 +82,7 @@ function testFieldAvailableLanguages() {
field_test_entity_info_translatable('test_entity', TRUE);
// Test hook_field_languages() invocation on a translatable field.
state()->set('field_test.field_available_languages_alter', TRUE);
\Drupal::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) {
......@@ -381,7 +381,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.
state()->set('field_test.language_fallback', FALSE);
\Drupal::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, $this->field_name, $requested_langcode);
......
......@@ -14,7 +14,7 @@
function field_test_entity_info() {
// If requested, clear the field cache while this is being called. See
// Drupal\field\Tests\FieldInfoTest::testFieldInfoCache().
if (state()->get('field_test.clear_info_cache_in_hook_entity_info')) {
if (Drupal::state()->get('field_test.clear_info_cache_in_hook_entity_info')) {
field_info_cache_clear();
}
}
......@@ -56,7 +56,7 @@ function field_test_entity_bundle_info_alter(&$bundles) {
$entity_info = entity_get_info();
foreach ($bundles as $entity_type => $info) {
if ($entity_info[$entity_type]['module'] == 'field_test') {
$bundles[$entity_type] = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles[$entity_type] = Drupal::state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
if ($entity_type == 'test_entity_bundle') {
$bundles[$entity_type] += array('test_entity_2' => array('label' => 'Test entity 2'));
}
......@@ -90,9 +90,9 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable
* name will be used.
*/
function field_test_create_bundle($bundle, $text = NULL) {
$bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles += array($bundle => array('label' => $text ? $text : $bundle));
state()->set('field_test.bundles', $bundles);
Drupal::state()->set('field_test.bundles', $bundles);
$info = entity_get_info();
foreach ($info as $type => $type_info) {
......@@ -111,10 +111,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 = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles[$bundle_new] = $bundles[$bundle_old];
unset($bundles[$bundle_old]);
state()->set('field_test.bundles', $bundles);
Drupal::state()->set('field_test.bundles', $bundles);
$info = entity_get_info();
foreach ($info as $type => $type_info) {
......@@ -131,9 +131,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 = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
$bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
unset($bundles[$bundle]);
state()->set('field_test.bundles', $bundles);
Drupal::state()->set('field_test.bundles', $bundles);
$info = entity_get_info();
foreach ($info as $type => $type_info) {
......
......@@ -106,7 +106,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 (state()->get('field_test.field_available_languages_alter')) {
if (Drupal::state()->get('field_test.field_available_languages_alter')) {
// Add an unavailable language code.
$langcodes[] = 'xx';
// Remove an available language code.
......@@ -119,7 +119,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 (state()->get('field_test.language_fallback') ?: TRUE) {
if (Drupal::state()->get('field_test.language_fallback') ?: TRUE) {
field_language_fallback($display_langcode, $context['entity'], $context['langcode']);
}
}
......
......@@ -71,10 +71,10 @@ function field_test_field_storage_details_alter(&$details, $field) {
*/
function _field_test_storage_data($data = NULL) {
if (!isset($data)) {
return state()->get('field_test.storage_data');
return Drupal::state()->get('field_test.storage_data');
}
else {
state()->set('field_test.storage_data', $data);
Drupal::state()->set('field_test.storage_data', $data);
}
}
......
......@@ -77,7 +77,7 @@ function field_sql_storage_update_dependencies() {
* Renames the 'language' column to 'langcode' in field data tables.
*/
function field_sql_storage_update_8000(&$sandbox) {
// Get field definitions from config, and deleted fields from state().
// Get field definitions from config, and deleted fields from state system.
$config_names = config_get_storage_names_with_prefix('field.field');
$deleted_fields = Drupal::state()->get('field.field.deleted') ?: array();
// Ditch UUID keys, we will iterate through deleted fields using a numeric
......
......@@ -249,7 +249,7 @@ function field_ui_element_info() {
function field_ui_entity_bundle_create($entity_type, $bundle) {
// When a new bundle is created, the menu needs to be rebuilt to add our
// menu item tabs.
state()->set('menu_rebuild_needed', TRUE);
Drupal::state()->set('menu_rebuild_needed', TRUE);
}
/**
......@@ -258,7 +258,7 @@ function field_ui_entity_bundle_create($entity_type, $bundle) {
function field_ui_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
// When a bundle is renamed, the menu needs to be rebuilt to add our
// menu item tabs.
state()->set('menu_rebuild_needed', TRUE);
Drupal::state()->set('menu_rebuild_needed', TRUE);
}
/**
......@@ -355,12 +355,12 @@ function field_ui_library_info() {