diff --git a/core/modules/config/src/Tests/ConfigSchemaTest.php b/core/modules/config/src/Tests/ConfigSchemaTest.php index 7005002..c7a71aa 100644 --- a/core/modules/config/src/Tests/ConfigSchemaTest.php +++ b/core/modules/config/src/Tests/ConfigSchemaTest.php @@ -273,7 +273,7 @@ function testSchemaData() { $property = $meta->get('page')->get('front'); $this->assertTrue($property instanceof StringInterface, 'Got the right wrapper fo the page.front property.'); - $this->assertEqual($property->getValue(), 'user/login', 'Got the right value for page.front data.'); + $this->assertEqual($property->getValue(), 'system/frontpage', 'Got the right value for page.front data.'); $definition = $property->getDataDefinition(); $this->assertTrue(empty($definition['translatable']), 'Got the right translatability setting for page.front data.'); @@ -281,13 +281,13 @@ function testSchemaData() { $list = $meta->get('page'); $this->assertEqual(count($list), 3, 'Got a list with the right number of properties for site page data'); $this->assertTrue(isset($list['front']) && isset($list['403']) && isset($list['404']), 'Got a list with the right properties for site page data.'); - $this->assertEqual($list['front']->getValue(), 'user/login', 'Got the right value for page.front data from the list.'); + $this->assertEqual($list['front']->getValue(), 'system/frontpage', 'Got the right value for page.front data from the list.'); // And test some ComplexDataInterface methods. $properties = $list->getProperties(); $this->assertTrue(count($properties) == 3 && $properties['front'] == $list['front'], 'Got the right properties for site page.'); $values = $list->toArray(); - $this->assertTrue(count($values) == 3 && $values['front'] == 'user/login', 'Got the right property values for site page.'); + $this->assertTrue(count($values) == 3 && $values['front'] == 'system/frontpage', 'Got the right property values for site page.'); // Now let's try something more complex, with nested objects. $wrapper = \Drupal::service('config.typed')->get('image.style.large'); diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php index 16fa5ac..702a66c 100644 --- a/core/modules/language/src/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php @@ -93,18 +93,18 @@ protected function doTestLanguageBlockAuthenticated($block_label) { $labels[] = (string) $list_item->a; } $expected_list_items = array( - 0 => array('langcode_class' => 'en', 'data-drupal-link-system-path' => 'user/2'), - 1 => array('langcode_class' => 'fr', 'data-drupal-link-system-path' => 'user/2'), + 0 => array('langcode_class' => 'en', 'data-drupal-link-system-path' => ''), + 1 => array('langcode_class' => 'fr', 'data-drupal-link-system-path' => ''), ); $this->assertIdentical($list_items, $expected_list_items, 'The list items have the correct attributes that will allow the drupal.active-link library to mark them as active.'); $expected_anchors = array( - 0 => array('hreflang' => 'en', 'data-drupal-link-system-path' => 'user/2'), - 1 => array('hreflang' => 'fr', 'data-drupal-link-system-path' => 'user/2'), + 0 => array('hreflang' => 'en', 'data-drupal-link-system-path' => ''), + 1 => array('hreflang' => 'fr', 'data-drupal-link-system-path' => ''), ); $this->assertIdentical($anchors, $expected_anchors, 'The anchors have the correct attributes that will allow the drupal.active-link library to mark them as active.'); $settings = $this->getDrupalSettings(); - $this->assertIdentical($settings['path']['currentPath'], 'user/2', 'drupalSettings.path.currentPath is set correctly to allow drupal.active-link to mark the correct links as active.'); - $this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.'); + $this->assertIdentical($settings['path']['currentPath'], 'system/frontpage', 'drupalSettings.path.currentPath is set correctly to allow drupal.active-link to mark the correct links as active.'); + $this->assertIdentical($settings['path']['isFront'], TRUE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.'); $this->assertIdentical($settings['path']['currentLanguage'], 'en', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.'); $this->assertIdentical($labels, array('English', 'français'), 'The language links labels are in their own language on the language switcher block.'); } diff --git a/core/modules/system/config/install/system.site.yml b/core/modules/system/config/install/system.site.yml index 10e2be2..62d8b8c 100644 --- a/core/modules/system/config/install/system.site.yml +++ b/core/modules/system/config/install/system.site.yml @@ -5,7 +5,7 @@ slogan: '' page: 403: '' 404: '' - front: user/login + front: system/frontpage admin_compact_mode: false weight_select_max: 100 langcode: en diff --git a/core/modules/system/src/Controller/DefaultFrontpageController.php b/core/modules/system/src/Controller/DefaultFrontpageController.php new file mode 100644 index 0000000..4a8628f --- /dev/null +++ b/core/modules/system/src/Controller/DefaultFrontpageController.php @@ -0,0 +1,56 @@ + $this->t('No front page has been configured yet.'), + ); + + $url = Url::fromRoute('system.site_information_settings'); + $build['links'] = array( + '#theme' => 'links', + '#links' => array( + 'site-settings' => array( + 'title' => $this->t('Edit site settings'), + 'url' => $url, + ), + ), + '#access' => $url->access(), + ); + + return $build; + } + + + /** + * Returns the title for the default front page. + * + * @return array + * The render array for the default front page. + */ + public function getTitle() { + $title = $this->config('system.site')->get('name'); + return $this->t('Welcome to @title', ['@title' => $title]); + } + +} diff --git a/core/modules/system/src/Form/SiteInformationForm.php b/core/modules/system/src/Form/SiteInformationForm.php index fec470c..d8add2b 100644 --- a/core/modules/system/src/Form/SiteInformationForm.php +++ b/core/modules/system/src/Form/SiteInformationForm.php @@ -107,7 +107,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#title' => t('Front page'), '#open' => TRUE, ); - $front_page = $site_config->get('page.front') != 'user/login' ? $this->aliasManager->getAliasByPath($site_config->get('page.front')) : ''; + $front_page = $site_config->get('page.front') != 'system/frontpage' ? $this->aliasManager->getAliasByPath($site_config->get('page.front')) : ''; $form['front_page']['site_frontpage'] = array( '#type' => 'textfield', '#title' => t('Default front page'), @@ -147,8 +147,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function validateForm(array &$form, FormStateInterface $form_state) { // Check for empty front page path. if ($form_state->isValueEmpty('site_frontpage')) { - // Set to default "user/login". - form_set_value($form['front_page']['site_frontpage'], 'user/login', $form_state); + // Set to default "system/frontpage". + form_set_value($form['front_page']['site_frontpage'], 'system/frontpage', $form_state); } else { // Get the normal path of the front page. diff --git a/core/modules/system/src/Tests/DrupalKernel/ContentNegotiationTest.php b/core/modules/system/src/Tests/DrupalKernel/ContentNegotiationTest.php index f45f574..036a5d5 100644 --- a/core/modules/system/src/Tests/DrupalKernel/ContentNegotiationTest.php +++ b/core/modules/system/src/Tests/DrupalKernel/ContentNegotiationTest.php @@ -24,7 +24,7 @@ class ContentNegotiationTest extends WebTestBase { * * @see http://drupal.org/node/1716790 */ - function testBogusAcceptHeader() { + public function testBogusAcceptHeader() { $tests = array( // @see https://bugs.webkit.org/show_bug.cgi?id=27267 'Firefox 3.5 (2009)' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', @@ -42,8 +42,9 @@ function testBogusAcceptHeader() { ); foreach ($tests as $case => $header) { $this->drupalGet('', array(), array('Accept: ' . $header)); + $this->assertResponse(200); $this->assertNoText('Unsupported Media Type', '"Unsupported Media Type" not found for ' . $case); - $this->assertText(t('Log in'), '"Log in" found for ' . $case); + $this->assertText('No front page has been configured yet.', 'Frontpage found for ' . $case); } } diff --git a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php index cdae9ec..f2fc15c 100644 --- a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php +++ b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php @@ -70,9 +70,14 @@ protected function setUpProfile() { * Confirms that the installation succeeded. */ public function testInstalled() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); + // Confirm that we are logged-in after installation. + $this->drupalGet('user/1'); + $this->assertResponse(200); $this->assertText($this->root_user->getUsername()); } diff --git a/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php index 63bb9a8..7baa4ca 100644 --- a/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php @@ -29,8 +29,10 @@ protected function setUp() { * Verifies that installation succeeded. */ public function testInstaller() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); } } diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php index c97899c..8c30606 100644 --- a/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php @@ -60,8 +60,10 @@ protected function setUpSettings() { * Verifies that installation succeeded. */ public function testInstaller() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); } } diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php index 4645668..2a920a6 100644 --- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php @@ -70,8 +70,10 @@ protected function setUpSettings() { * Verifies that installation succeeded. */ public function testInstaller() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); } } diff --git a/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php b/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php index cd7bce5..3b57d30 100644 --- a/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php @@ -47,8 +47,10 @@ protected function setUpLanguage() { * Confirms that the installation succeeded. */ public function testInstalled() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); } } diff --git a/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php b/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php index 4c74ddc..790689c 100644 --- a/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php @@ -42,8 +42,10 @@ protected function setUpLanguage() { * Confirms that the installation succeeded. */ public function testInstalled() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); } } diff --git a/core/modules/system/src/Tests/Installer/InstallerTest.php b/core/modules/system/src/Tests/Installer/InstallerTest.php index 760a942..6db5582 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTest.php @@ -20,16 +20,21 @@ class InstallerTest extends InstallerTestBase { * Ensures that the user page is available after installation. */ public function testInstaller() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); - // Confirm that we are logged-in after installation. - $this->assertText($this->root_user->getUsername()); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); // Verify that the confirmation message appears. require_once DRUPAL_ROOT . '/core/includes/install.inc'; $this->assertRaw(t('Congratulations, you installed @drupal!', array( '@drupal' => drupal_install_profile_distribution_name(), ))); + + // Confirm that we are logged-in after installation. + $this->drupalGet('user/1'); + $this->assertResponse(200); + $this->assertText($this->root_user->getUsername()); } } diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php index abecc2a..c129e99 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php @@ -49,8 +49,10 @@ protected function setUpLanguage() { * Verifies that installation succeeded. */ public function testInstaller() { - $this->assertUrl('user/1'); + $this->assertUrl(''); $this->assertResponse(200); + $this->assertText('No front page has been configured yet.'); + $this->assertLink('Edit site settings'); $account = User::load(0); $this->assertEqual($account->language()->getId(), 'de', 'Anonymous user is German.'); diff --git a/core/modules/system/src/Tests/System/AdminTest.php b/core/modules/system/src/Tests/System/AdminTest.php index fee3cd9..92d6d9c 100644 --- a/core/modules/system/src/Tests/System/AdminTest.php +++ b/core/modules/system/src/Tests/System/AdminTest.php @@ -148,15 +148,10 @@ protected function getTopLevelMenuLinks() { /** * Test compact mode. */ - function testCompactMode() { - // The front page defaults to 'user/login', which redirects to 'user/{user}' - // for authenticated users. We cannot use '', since this does not - // match the redirected url. - $frontpage_url = 'user/' . $this->admin_user->id(); - + public function testCompactMode() { $this->drupalGet('admin/compact/on'); $this->assertResponse(200, 'A valid page is returned after turning on compact mode.'); - $this->assertUrl($frontpage_url, array(), 'The user is redirected to the front page after turning on compact mode.'); + $this->assertUrl('', array(), 'The user is redirected to the front page after turning on compact mode.'); $this->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode turns on.'); $this->drupalGet('admin/compact/on'); $this->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode remains on after a repeat call.'); @@ -165,7 +160,7 @@ function testCompactMode() { $this->drupalGet('admin/compact/off'); $this->assertResponse(200, 'A valid page is returned after turning off compact mode.'); - $this->assertUrl($frontpage_url, array(), 'The user is redirected to the front page after turning off compact mode.'); + $this->assertUrl('', array(), 'The user is redirected to the front page after turning off compact mode.'); $this->assertEqual($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'deleted', 'Compact mode turns off.'); $this->drupalGet('admin/compact/off'); $this->assertEqual($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'deleted', 'Compact mode remains off after a repeat call.'); diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 4d54d00..f645472 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -410,6 +410,14 @@ system.timezone: requirements: _access: 'TRUE' +system.default_frontpage: + path: '/system/frontpage' + defaults: + _content: '\Drupal\system\Controller\DefaultFrontpageController::getFrontpage' + _title_callback: '\Drupal\system\Controller\DefaultFrontpageController::getTitle' + requirements: + _access: 'TRUE' + system.admin_config: path: '/admin/config' defaults: