diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index 818e6ca..c2905ef 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -16,7 +16,6 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Language\LanguageInterface; use Drupal\language\Config\LanguageConfigOverride; -use Drupal\Core\Language\LanguageInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\locale\StringStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php index b436629..e1b939c 100644 --- a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php +++ b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php @@ -60,7 +60,7 @@ function setUp() { public function testTranslationLink() { $this->drupalGet('test-entity-translations-link'); $this->assertLinkByHref('user/1/translations'); - $this->assertNoLinkByHref('user/99/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.'); + $this->assertNoLinkByHref('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.'); } } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php deleted file mode 100644 index 369645c..0000000 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ /dev/null @@ -1,368 +0,0 @@ - 'Field info tests', - 'description' => 'Get information about existing fields, instances and bundles.', - 'group' => 'Field API', - ); - } - - /** - * Test that field types and field definitions are correctly cached. - */ - function testFieldInfo() { - // Test that field_test module's fields, widgets, and formatters show up. - - $field_test_info = $this->getExpectedFieldTypeDefinition(); - $entity_type = \Drupal::service('plugin.manager.field.field_type')->getDefinitions(); - foreach ($field_test_info as $t_key => $field_type) { - foreach ($field_type as $key => $val) { - $this->assertEqual($entity_type[$t_key][$key], $val, format_string('Field type %t_key key %key is %value', array('%t_key' => $t_key, '%key' => $key, '%value' => print_r($val, TRUE)))); - } - $this->assertEqual($entity_type[$t_key]['provider'], 'field_test', 'Field type field_test module appears.'); - } - - // Verify that no unexpected instances exist. - $instances = field_info_instances('entity_test'); - $expected = array(); - $this->assertIdentical($instances, $expected, format_string("field_info_instances('entity_test') returns %expected.", array('%expected' => var_export($expected, TRUE)))); - $instances = field_info_instances('entity_test', 'entity_test'); - $this->assertIdentical($instances, array(), "field_info_instances('entity_test', 'entity_test') returns an empty array."); - - // Create a field, verify it shows up. - $core_fields = field_info_fields(); - $field = entity_create('field_config', array( - 'name' => drupal_strtolower($this->randomName()), - 'entity_type' => 'entity_test', - 'type' => 'test_field', - )); - $field->save(); - $fields = field_info_fields(); - $this->assertEqual(count($fields), count($core_fields) + 1, 'One new field exists'); - $this->assertEqual($fields[$field->uuid]->getName(), $field->getName(), 'info fields contains field name'); - $this->assertEqual($fields[$field->uuid]->getType(), $field->getType(), 'info fields contains field type'); - $this->assertEqual($fields[$field->uuid]->module, 'field_test', 'info fields contains field module'); - $settings = array('test_field_setting' => 'dummy test string'); - foreach ($settings as $key => $val) { - $this->assertEqual($fields[$field->uuid]->getSetting($key), $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val))); - } - $this->assertEqual($fields[$field->uuid]->getCardinality(), 1, 'info fields contains cardinality 1'); - - // Create an instance, verify that it shows up - $instance_definition = array( - 'field_name' => $field->getName(), - 'entity_type' => 'entity_test', - 'bundle' => 'entity_test', - 'label' => $this->randomName(), - 'description' => $this->randomName(), - 'weight' => mt_rand(0, 127), - ); - $instance = entity_create('field_instance_config', $instance_definition); - $instance->save(); - - $entity_type = \Drupal::entityManager()->getDefinition('entity_test'); - $instances = field_info_instances('entity_test', $instance->bundle); - $this->assertEqual(count($instances), 1, format_string('One instance shows up in info when attached to a bundle on a @label.', array( - '@label' => $entity_type->getLabel(), - ))); - $this->assertTrue($instance_definition < $instances[$instance->getName()], 'Instance appears in info correctly'); - - // Test a valid entity type but an invalid bundle. - $instances = field_info_instances('entity_test', 'invalid_bundle'); - $this->assertIdentical($instances, array(), "field_info_instances('entity_test', 'invalid_bundle') returns an empty array."); - - // Test invalid entity type and bundle. - $instances = field_info_instances('invalid_entity', $instance->bundle); - $this->assertIdentical($instances, array(), "field_info_instances('invalid_entity', 'entity_test') returns an empty array."); - - // Test invalid entity type, no bundle provided. - $instances = field_info_instances('invalid_entity'); - $this->assertIdentical($instances, array(), "field_info_instances('invalid_entity') returns an empty array."); - - // Test with an entity type that has no bundles. - $instances = field_info_instances('user'); - $expected = array(); - $this->assertIdentical($instances, $expected, format_string("field_info_instances('user') returns %expected.", array('%expected' => var_export($expected, TRUE)))); - $instances = field_info_instances('user', 'user'); - $this->assertIdentical($instances, array(), "field_info_instances('user', 'user') returns an empty array."); - - // Test that querying for invalid entity types does not add entries in the - // list returned by field_info_instances(). - field_info_cache_clear(); - field_info_instances('invalid_entity', 'invalid_bundle'); - // Simulate new request by clearing static caches. - drupal_static_reset(); - field_info_instances('invalid_entity', 'invalid_bundle'); - $instances = field_info_instances(); - $this->assertFalse(isset($instances['invalid_entity']), 'field_info_instances() does not contain entries for the invalid entity type that was queried before'); - } - - /** - * Test that cached field definitions are ready for current runtime context. - */ - function testFieldPrepare() { - $field_definition = array( - 'name' => 'field', - 'entity_type' => 'entity_test', - 'type' => 'test_field', - ); - $field = entity_create('field_config', $field_definition); - $field->save(); - - // Simulate a stored field definition missing a field setting (e.g. a - // third-party module adding a new field setting has been enabled, and - // existing fields do not know the setting yet). - \Drupal::config('field.field.' . $field->id()) - ->set('settings', array()) - ->save(); - field_info_cache_clear(); - - // Read the field back. - $field = field_info_field('entity_test', $field_definition['name']); - - // Check that all expected settings are in place. - $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); - $this->assertEqual($field->settings, $field_type_manager->getDefaultSettings($field_definition['type']), 'All expected default field settings are present.'); - } - - /** - * Test that cached instance definitions are ready for current runtime context. - */ - function testInstancePrepare() { - $field_definition = array( - 'name' => 'field', - 'entity_type' => 'entity_test', - 'type' => 'test_field', - ); - entity_create('field_config', $field_definition)->save(); - $instance_definition = array( - 'field_name' => $field_definition['name'], - 'entity_type' => 'entity_test', - 'bundle' => 'entity_test', - ); - $instance = entity_create('field_instance_config', $instance_definition); - $instance->save(); - - // Simulate a stored instance definition missing various settings (e.g. a - // third-party module adding instance settings has been enabled, but - // existing instances do not know the new settings). - \Drupal::config('field.instance.' . $instance->id()) - ->set('settings', array()) - ->save(); - field_info_cache_clear(); - - // Read the instance back. - $instance = field_info_instance($instance_definition['entity_type'], $instance_definition['field_name'], $instance_definition['bundle']); - - // Check that all expected instance settings are in place. - $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); - $this->assertEqual($instance->settings, $field_type_manager->getDefaultInstanceSettings($field_definition['type']) , 'All expected instance settings are present.'); - } - - /** - * Test that instances on disabled entity types are filtered out. - */ - function testInstanceDisabledEntityType() { - // Disabling a module invokes user_modules_uninstalled() and calls - // drupal_flush_all_caches(). Install the necessary schema to support this. - $this->installSchema('user', array('users_data')); - $this->installSchema('system', array('router')); - - // For this test the field type and the entity type must be exposed by - // different modules. - $field_definition = array( - 'name' => 'field', - 'entity_type' => 'entity_test', - 'type' => 'test_field', - ); - entity_create('field_config', $field_definition)->save(); - $instance_definition = array( - 'field_name' => 'field', - 'entity_type' => 'entity_test', - 'bundle' => 'entity_test', - ); - entity_create('field_instance_config', $instance_definition)->save(); - - $this->assertNotNull(field_info_instance('entity_test', 'field', 'entity_test'), 'Instance is returned on enabled entity types.'); - // Disable comment module. This clears field_info cache. - module_uninstall(array('entity_test')); - $this->assertNull(field_info_instance('entity_test', 'field', 'entity_test'), 'No instances are returned on disabled entity types.'); - } - - /** - * Test field_info_field_map(). - */ - function testFieldMap() { - // We will overlook fields created by the 'standard' installation profile. - $exclude = field_info_field_map(); - - // Create a new bundle for 'entity_test' entity type. - entity_test_create_bundle('test_bundle_2'); - - // Create a couple fields. - $fields = array( - array( - 'name' => 'field_1', - 'entity_type' => 'entity_test', - 'type' => 'test_field', - ), - array( - 'name' => 'field_2', - 'entity_type' => 'entity_test', - 'type' => 'hidden_test_field', - ), - array( - 'name' => 'field_2', - 'entity_type' => 'entity_test_cache', - 'type' => 'hidden_test_field', - ), - ); - foreach ($fields as $field) { - entity_create('field_config', $field)->save(); - } - - // Create a couple instances. - $instances = array( - array( - 'field_name' => 'field_1', - 'entity_type' => 'entity_test', - 'bundle' => 'entity_test', - ), - array( - 'field_name' => 'field_1', - 'entity_type' => 'entity_test', - 'bundle' => 'test_bundle_2', - ), - array( - 'field_name' => 'field_2', - 'entity_type' => 'entity_test', - 'bundle' => 'entity_test', - ), - array( - 'field_name' => 'field_2', - 'entity_type' => 'entity_test_cache', - 'bundle' => 'entity_test', - ), - ); - foreach ($instances as $instance) { - entity_create('field_instance_config', $instance)->save(); - } - - $expected = array( - 'entity_test' => array( - 'field_1' => array( - 'type' => 'test_field', - 'bundles' => array('entity_test', 'test_bundle_2'), - ), - 'field_2' => array( - 'type' => 'hidden_test_field', - 'bundles' => array('entity_test'), - ), - ), - 'entity_test_cache' => array( - 'field_2' => array( - 'type' => 'hidden_test_field', - 'bundles' => array('entity_test') - ), - ), - ); - - // Check that the field map is correct. - $map = field_info_field_map(); - $map = array_diff_key($map, $exclude); - $this->assertEqual($map, $expected); - } - - /** - * Test that the field_info settings convenience functions work. - */ - function testSettingsInfo() { - $info = $this->getExpectedFieldTypeDefinition(); - foreach ($info as $type => $data) { - $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); - $this->assertIdentical($field_type_manager->getDefaultSettings($type), $data['class']::defaultSettings(), format_string("field settings service returns %type's field settings", array('%type' => $type))); - $this->assertIdentical($field_type_manager->getDefaultInstanceSettings($type), $data['class']::defaultInstanceSettings(), format_string("field instance settings service returns %type's field instance settings", array('%type' => $type))); - } - } - - /** - * Tests that the field info cache can be built correctly. - */ - function testFieldInfoCache() { - // Create a test field and ensure it's in the array returned by - // field_info_fields(). - $field_name = drupal_strtolower($this->randomName()); - $field = entity_create('field_config', array( - 'name' => $field_name, - 'entity_type' => 'entity_test', - 'type' => 'test_field', - )); - $field->save(); - $fields = field_info_fields(); - $this->assertTrue(isset($fields[$field->uuid]), 'The test field is initially found in the array returned by field_info_fields().'); - - // Now rebuild the field info cache, and set a variable which will cause - // the cache to be cleared while it's being rebuilt; see - // field_test_entity_type_build(). Ensure the test field is still in the returned - // array. - field_info_cache_clear(); - \Drupal::state()->set('field_test.clear_info_cache_in_hook_entity_type_build', TRUE); - $fields = field_info_fields(); - $this->assertTrue(isset($fields[$field->uuid]), 'The test field is found in the array returned by field_info_fields() even if its cache is cleared while being rebuilt.'); - } - - /** - * Test that the widget definition functions work. - */ - function testWidgetDefinition() { - $widget_definition = \Drupal::service('plugin.manager.field.widget')->getDefinition('test_field_widget_multiple'); - - // Test if hook_field_widget_info_alter is beïng called. - $this->assertTrue(in_array('test_field', $widget_definition['field_types']), "The 'test_field_widget_multiple' widget is enabled for the 'test_field' field type in field_test_field_widget_info_alter()."); - } - - /** - * Returns field info definition. - */ - protected function getExpectedFieldTypeDefinition() { - return array( - 'test_field' => array( - 'label' => t('Test field'), - 'description' => t('Dummy field type used for tests.'), - 'default_widget' => 'test_field_widget', - 'default_formatter' => 'field_test_default', - 'class' => 'Drupal\field_test\Plugin\Field\FieldType\TestItem', - ), - 'shape' => array( - 'label' => t('Shape'), - 'description' => t('Another dummy field type.'), - 'default_widget' => 'test_field_widget', - 'default_formatter' => 'field_test_default', - 'class' => 'Drupal\field_test\Plugin\Field\FieldType\ShapeItem', - ), - 'hidden_test_field' => array( - 'no_ui' => TRUE, - 'label' => t('Hidden from UI test field'), - 'description' => t('Dummy hidden field type used for tests.'), - 'default_widget' => 'test_field_widget', - 'default_formatter' => 'field_test_default', - 'class' => 'Drupal\field_test\Plugin\Field\FieldType\HiddenTestItem', - ), - ); - } - -} diff --git a/core/modules/language/src/LanguageServiceProvider.php b/core/modules/language/src/LanguageServiceProvider.php index 267e3fb..a565c1c 100644 --- a/core/modules/language/src/LanguageServiceProvider.php +++ b/core/modules/language/src/LanguageServiceProvider.php @@ -11,7 +11,6 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderBase; use Drupal\Core\Language\LanguageInterface as BaseLanguageInterface; -use Drupal\Core\Language\LanguageInterface as CoreLanguageInterface; use Symfony\Component\DependencyInjection\Reference; /** diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeController.php b/core/modules/node/lib/Drupal/node/Controller/NodeController.php deleted file mode 100644 index 7874ebf..0000000 --- a/core/modules/node/lib/Drupal/node/Controller/NodeController.php +++ /dev/null @@ -1,133 +0,0 @@ -entityManager()->getStorage('node_type')->loadMultiple() as $type) { - if ($this->entityManager()->getAccessController('node')->createAccess($type->type)) { - $content[$type->type] = $type; - } - } - - // Bypass the node/add listing if only one content type is available. - if (count($content) == 1) { - $type = array_shift($content); - return $this->redirect('node.add', array('node_type' => $type->type)); - } - - return array( - '#theme' => 'node_add_list', - '#content' => $content, - ); - } - - /** - * Provides the node submission form. - * - * @param \Drupal\node\NodeTypeInterface $node_type - * The node type entity for the node. - * - * @return array - * A node submission form. - */ - public function add(NodeTypeInterface $node_type) { - $account = $this->currentUser(); - $langcode = $this->moduleHandler()->invoke('language', 'get_default_langcode', array('node', $node_type->type)); - - $node = $this->entityManager()->getStorage('node')->create(array( - 'uid' => $account->id(), - 'name' => $account->getUsername() ?: '', - 'type' => $node_type->type, - 'langcode' => $langcode ? $langcode : $this->languageManager()->getCurrentLanguage()->getId(), - )); - - $form = $this->entityFormBuilder()->getForm($node); - - return $form; - } - - /** - * Displays a node revision. - * - * @param int $node_revision - * The node revision ID. - * - * @return array - * An array suitable for drupal_render(). - */ - public function revisionShow($node_revision) { - $node = $this->entityManager()->getStorage('node')->loadRevision($node_revision); - $node_view_controller = new NodeViewController($this->entityManager); - $page = $node_view_controller->view($node); - unset($page['nodes'][$node->id()]['#cache']); - return $page; - } - - /** - * Page title callback for a node revision. - * - * @param int $node_revision - * The node revision ID. - * - * @return string - * The page title. - */ - public function revisionPageTitle($node_revision) { - $node = $this->entityManager()->getStorage('node')->loadRevision($node_revision); - return $this->t('Revision of %title from %date', array('%title' => $node->label(), '%date' => format_date($node->getRevisionCreationTime()))); - } - - /** - * @todo Remove node_revision_overview(). - */ - public function revisionOverview(NodeInterface $node) { - module_load_include('pages.inc', 'node'); - return node_revision_overview($node); - } - - /** - * The _title_callback for the node.add route. - * - * @param \Drupal\node\NodeTypeInterface $node_type - * The current node. - * - * @return string - * The page title. - */ - public function addPageTitle(NodeTypeInterface $node_type) { - return $this->t('Create @name', array('@name' => $node_type->name)); - } - -} diff --git a/core/modules/node/lib/Drupal/node/NodeStorage.php b/core/modules/node/lib/Drupal/node/NodeStorage.php deleted file mode 100644 index a95d69e..0000000 --- a/core/modules/node/lib/Drupal/node/NodeStorage.php +++ /dev/null @@ -1,62 +0,0 @@ -database->query( - 'SELECT vid FROM {node_revision} WHERE nid=:nid ORDER BY vid', - array(':nid' => $node->id()) - )->fetchCol(); - } - - /** - * {@inheritdoc} - */ - public function userRevisionIds(AccountInterface $account) { - return $this->database->query( - 'SELECT vid FROM {node_field_revision} WHERE uid = :uid ORDER BY vid', - array(':uid' => $account->id()) - )->fetchCol(); - } - - /** - * {@inheritdoc} - */ - public function updateType($old_type, $new_type) { - return $this->database->update('node') - ->fields(array('type' => $new_type)) - ->condition('type', $old_type) - ->execute(); - } - - /** - * {@inheritdoc} - */ - public function clearRevisionsLanguage($language) { - return $this->database->update('node_revision') - ->fields(array('langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)) - ->condition('langcode', $language->id) - ->execute(); - } -} diff --git a/core/modules/node/src/Controller/NodeController.php b/core/modules/node/src/Controller/NodeController.php index 812a3f8..f9a8335 100644 --- a/core/modules/node/src/Controller/NodeController.php +++ b/core/modules/node/src/Controller/NodeController.php @@ -109,7 +109,7 @@ public function add(NodeTypeInterface $node_type) { 'uid' => $account->id(), 'name' => $account->getUsername() ?: '', 'type' => $node_type->type, - 'langcode' => $langcode ? $langcode : $this->languageManager()->getCurrentLanguage()->id, + 'langcode' => $langcode ? $langcode : $this->languageManager()->getCurrentLanguage()->getId(), )); $form = $this->entityFormBuilder()->getForm($node); diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php index 1d5c15b..1240ec1 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php @@ -7,8 +7,8 @@ namespace Drupal\system\Tests\Entity; -use Drupal\field\Entity\FieldConfig; use Drupal\Core\Language\LanguageInterface; +use Drupal\field\Entity\FieldConfig; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language;