diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index ff8f1b5..c9959a5 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -122,8 +122,8 @@ public static function createFromPath($path) { else { // Look up the route name and parameters used for the given path. try { - // Path aliases are added on the request level, so we need to manually - // call it. + // Path aliases are added on the request level (instead of the routing + // level), so we need to convert the path manually. // @see \Drupal\Core\EventSubscriber\PathSubscriber $path = \Drupal::service('path.alias_manager.cached')->getPathByAlias($path); $result = \Drupal::service('router')->match('/' . $path); diff --git a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php index 74d9e72..b4f1449 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php +++ b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php @@ -63,13 +63,6 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel /** * {@inheritdoc} */ - public static function mainPropertyName() { - return 'url'; - } - - /** - * {@inheritdoc} - */ public static function schema(FieldStorageDefinitionInterface $field_definition) { return array( 'columns' => array( @@ -167,8 +160,12 @@ public function preSave() { * {@inheritdoc} */ public function isEmpty() { - $value = $this->get('url')->getValue(); - return $value === NULL || $value === ''; + if ($this->isExternal()) { + return $this->url === NULL || $this->url === ''; + } + else { + return $this->route_name === NULL || $this->route_name === ''; + } } /** diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install index 4cb850d..6c6917f 100644 --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -43,12 +43,6 @@ function shortcut_schema() { 'not null' => TRUE, 'default' => 0, ), - 'link__url' => array( - 'description' => 'The URL of the link.', - 'type' => 'varchar', - 'length' => 2048, - 'not null' => FALSE, - ), 'link__route_name' => array( 'description' => 'The machine name of a defined Route this link represents.', 'type' => 'varchar', diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php index 840ca66..a63fb66 100644 --- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php @@ -62,6 +62,7 @@ public function testShortcutLinkAdd() { $this->assertResponse(200); $saved_set = shortcut_set_load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'link'); + $test['path'] = $test['path'] != '' ? $test['path'] : ''; $this->assertTrue(in_array($test['path'], $paths), 'Shortcut created: ' . $test['path']); $this->assertLink($title, 0, 'Shortcut link found on the page.'); } @@ -109,7 +110,7 @@ public function testShortcutLinkRename() { $shortcuts = $set->getShortcuts(); $shortcut = reset($shortcuts); - $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $new_link_name, 'link[0][url]' => $shortcut->link->url), t('Save')); + $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $new_link_name, 'link[0][url]' => $shortcut->getUrl()->toString()), t('Save')); $saved_set = shortcut_set_load($set->id()); $titles = $this->getShortcutInformation($saved_set, 'title'); $this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name); diff --git a/core/modules/shortcut/src/Tests/ShortcutTestBase.php b/core/modules/shortcut/src/Tests/ShortcutTestBase.php index 70b5170..fc5f848 100644 --- a/core/modules/shortcut/src/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/src/Tests/ShortcutTestBase.php @@ -109,7 +109,7 @@ function generateShortcutSet($label = '', $id = NULL) { * @param string $key * The array key indicating what information to extract from each link: * - 'title': Extract shortcut titles. - * - 'path': Extract shortcut paths. + * - 'link': Extract shortcut paths. * - 'id': Extract the shortcut ID. * * @return array @@ -119,8 +119,12 @@ function getShortcutInformation(ShortcutSetInterface $set, $key) { $info = array(); \Drupal::entityManager()->getStorage('shortcut')->resetCache(); foreach ($set->getShortcuts() as $shortcut) { - $main_property_name = $shortcut->{$key}->getFieldDefinition()->getMainPropertyName(); - $info[] = $shortcut->{$key}->{$main_property_name}; + if ($key == 'link') { + $info[] = ltrim($shortcut->getUrl()->toString(), '/'); + } + else { + $info[] = $shortcut->{$key}->value; + } } return $info; } diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index a749fdc..18c9a29 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -57,7 +57,6 @@ function standard_install() { 'title' => t('Add content'), 'weight' => -20, 'link' => array( - 'url' => 'node/add', 'route_name' => 'node.add_page', ), )); @@ -68,7 +67,6 @@ function standard_install() { 'title' => t('All content'), 'weight' => -19, 'link' => array( - 'url' => 'admin/content', 'route_name' => 'node.content_overview', ), ));